This chapter will uncover a non-obvious facet of quality GUI — user assistance as a hidden tool for building trust and speeding up work. Here you’ll discover a practical approach that transforms the interface from a collection of widgets into an accompanying assistant. You’ll learn the secret of why professional developers pay no less attention to the help system than to architecture.
Three levels of help will be covered — from concise tooltips to full-featured Online Help. You’ll see how to use QEvent::ToolTip, QTextBrowser, and external Qt Assistant to achieve the tangible effect of an “application that explains itself.” Just a few solutions — and the interface starts working for you.
Skipping this chapter means leaving the user experience at the “whatever happens” level.
This chapter includes ready-to-use code examples.
Chapter Self-Check
What three types of help are distinguished in Qt applications?Answer
Correct answer: Tooltip, “What’s This” help, and the help system (Online Help).
Why is it not recommended to use tooltips for elements with obvious purposes?Answer
Correct answer: Using tooltips loses its meaning when the explanation is unnecessary — repeating a button’s label in a tooltip adds no information and only distracts the user.
How do you remove a tooltip from a widget?Answer
Correct answer: You need to pass an empty string to the setToolTip() method.
Why is the event() method overridden in the example of creating a custom tooltip window?Answer
Correct answer: To catch the QEvent::ToolTip event type and handle it in a custom way, showing a custom window instead of the standard tooltip.
Why is QTimer::singleShot(3000, …) used in the custom tooltip example?Answer
Correct answer: The tooltip window must disappear after a certain time interval (3 seconds) to avoid cluttering the interface and to follow standard tooltip behavior.
Which class is used to implement a help system navigator with HTML support?Answer
Correct answer: QTextBrowser — it has everything needed to display text in HTML format with navigation support.
Why are the backwardAvailable(bool) and forwardAvailable(bool) signals connected to the setEnabled(bool) slots of buttons in the HelpBrowser example?Answer
Correct answer: This allows automatically enabling or disabling navigation buttons depending on the presence of navigation history (whether there’s somewhere to go back or forward).
What happens if you forget to call the show() method for a custom tooltip window?Answer
Correct answer: The tooltip window won’t be visible to the user, although all other operations (position setting, text) will execute correctly.
Why is HTML format recommended for help systems?Answer
Correct answer: HTML allows including graphics, links, formatting text, and there are many editors for creating it, including the possibility of manual editing.
What is the setSearchPaths() method used for in QTextBrowser?Answer
Correct answer: It sets a list of paths for searching documents where QTextBrowser will look for help files when following links.
Which key is used when launching Qt Assistant to enable remote control mode?Answer
Correct answer: The -enableRemoteControl key activates the remote control mode of Qt Assistant from the application.
What will the launchAssistant() function return if the assistant executable file is not found in PATH?Answer
Correct answer: The function will return false, since QProcess::startDetached() won’t be able to launch the process and will return false.
Why is Qt::ToolTip used as the window type in the MyWidget constructor?Answer
Correct answer: This flag creates a frameless window characteristic of tooltips, which visually corresponds to standard tooltip behavior.
Practice Assignments
Easy Level
Widget with Tooltips
Create an application with a window containing three buttons: “Save”, “Cancel”, and “Help”. Add a tooltip to each button explaining its function. For the “Help” button, use a multi-line HTML tooltip with formatting (heading and list of features).
Hints: Use the setToolTip() method to set tooltips. For HTML formatting, you can use tags <h3>, <ul>, <li>. Arrange buttons using QHBoxLayout. Remember that tooltips for buttons with obvious purposes should add information, not duplicate the text.
Medium Level
Custom Tooltip Window with Image
Create a widget that shows a custom tooltip window when hovering the cursor, containing not only text but also a small image (e.g., an icon). The tooltip should automatically hide after 5 seconds. Implement the ability to change the tooltip display time via a constructor parameter.
Hints: Inherit from QWidget and override the event() method. To create a window with an image, use QLabel with the setPixmap() method. Use QHBoxLayout to place the icon and text side by side. Don’t forget to set the Qt::ToolTip flag for the window. Save the display time as a class member.
Hard Level
Help System with Search and Navigation
Create a full-featured help system based on QTextBrowser with additional capabilities: navigation buttons (back, forward, home), a search bar for filtering content, and a bookmark list. Prepare several HTML pages with cross-references, including a main page (index.html) and 2-3 topic pages. Implement saving and loading bookmarks between sessions.
Hints: In addition to QTextBrowser and navigation buttons, add QLineEdit for search and QListWidget for bookmarks. Use the find() method in QTextBrowser for text search. For bookmarks, save the current page URL using source(). For saving between sessions, use QSettings. Create resource files (.qrc) for HTML pages. Use the sourceChanged() signal to track navigation.
💬 Join the Discussion!
Got a handle on help systems in Qt? Have questions about when to use simple tooltips versus when to create a full-featured help system?
Maybe you have interesting solutions for custom tooltips or experience integrating Qt Assistant?
Share your findings, ask questions, or help other readers make their applications more user-friendly!