The Work-around

Sometimes you want to use a library as it provides a lot of the functionality that you need.
However, sometimes some of the functions don't quite work as expected.
The solution is to find some way of working around the problem.

In this case it is the Qt GUI library.
There is a widget that can be used for displaying text, and it also works for simple HTML. Just the thing for displaying some nice help info.
My program uses HTML for displaying man pages and also for Info pages. However, it also displays the result of the --help option as plain text.

During testing I found that if I clicked on something while HTML was displayed, and then switched to plain text, it would use the font of whatever I last clicked on. The usual result was that my plain text would all be printed as though it were a HTML link.

It was obvious that something was not being reset when I replaced the contents of the widget. As you might imagine a widget that has much of the functionality of a word processor and web browser is quite complex and uses a lot of helper classes. One of these was not being reset.

I tried simply clearing the widget, replacing the under-lying document, setting the font, and quite a few other things - all to no avail.
Eventually I stumbled upon a function currentCharFormat(). Adding a line of code to reset this to a default value solved the problem.