Tips and Tricks

Getting rid of that annoying "?_=" in your clean internal path/URL

For reasons not exactly clear to this author, Wt prepends ?_= to every internal path by default. They way to fix this behavior is simple yet delicate. Doing it wrong can give you subtle and intermittent problems (I saw an occassional segfault when I wasn't using relative paths).
1) cd into the directory of your binary, then: `ln -s /usr/share/Wt/resources resources` (alternatively, make a copy of the Wt-provided resources folder to your current directory)
2) When launching your executable, tell it that that resources folder is also in your docroot. You can specify multiple docroots by separating them with a semicolon, like this: `--docroot ".;/resources"`. The double quotes are to prevent the shell from terminating the statement and are necessary. The way you type "/resources" must be exact (putting an absolute path, or even "resources" without the leading slash, will lead to problems!)
tl;dr:

$ cd /home/user/myProject/
$ ln -s /usr/share/Wt/resources resources
$ ./myWtApp --http-address 0.0.0.0 --http-port 6669 --docroot ".;/resources" 

Making a hard-copy of painted graphics

The primary use for the Wt painting API is to paint on a WPaintedWidget. Internally, this uses either a VML, SVG or HTML 5 canvas painting device to deliver the painting to the browser.

It is also possible to paint directly to an SVG image, which is a standardized generic vector graphics format, and increasingly supported by various tools.

You could use the SVG image as a starting point for exporting the painted graphics to raster format. Using the imagemagick or graphicsmagick libraries, you can convert from SVG to other formats using the library API or using the command line 'convert' tool. Using inkscape, a sophisticated SVG editor, you may get high quality SVG rendering (with, compared to imagemagick, much better font support) from the command-line (see the manpage). Another option may be librsvg.

The WSvgImage class allows you to easily create an SVG image, and save it to a (file) stream, using the following template:

WSvgImage image(400, 300);
WPainter painter(&image);

// paint things on the painter, like you normally do in WPaintedWidget::paintEvent().
//
// e.g. you could do WCartesianChart *c = ...
// c->paint(painter);

painter.end();
std::ofstream f("image.svg");
image.write(f);
f.close();

Creating .CUR files

Creating .CUR files which are valid in Firefox and Chrome can be quite a pickle, especially if you want to specify a custom hotspot.
This program allows you to create such .CUR files:
http://www.rw-designer.com/cursor-maker

Assert

Under some environments, when linking to the Wt library, 'assert' is removed from the code. This page shows a custom assert to be used with Wt: http://richelbilderbeek.nl/CppWtAssert.htm

Redirect HTTP to HTTPS

If you want to allow http connections but redirect them to https, you can use the following code in your WApplication constructor:

if(env.urlScheme() != "https")
{
    redirect("https://" + env.hostName() + url());
    return;
}