Qt World Summit 2023: Berlin awaits! Join us now
最新版Qt 6.3已正式发布。 了解更多。
最新バージョンQt6.5がご利用いただけます。 詳細はこちら

Qt hidden gems

As it happens to me usually, talking on IRC revealed another interesting topic to talk about. One developer was asking a question why part of his application window suddenly became blank after the mouse entered the window. Even though it's not really my area of expertise, I guessed it was related to painting, so after some conversation, I ended up suggesting setting the QT_FLUSH_PAINT environment variable, which causes the Qt painting system to paint the update regions yellow.

That reminded me of a BoF session my good friend Simon Hausmann gave at Akademy 2007 where he was going over a list of hidden gems. So I thought it was high time to rehash that list and tell you about it. By the way, if I'm not mistaken, the first inception of the Qt "tracer" graphics system was created by an audience member during Simon's session (I think it was Mirko Böhm, but I'm not sure now).

So what are the Qt hidden gems? I've collected a list for Qt, Qt Creator and Qt WebKit. Unfortunately, I don't know the Qt Mobility source code that well, so I couldn't create a list for that project.

Qt configure-time options

Enables "developer mode" for Qt, which means unit tests and some extra functionality is built in and exported. This also causes the Qt private headers to be installed. It's meant for testing and developing Qt, so not for the faint of heart. And if you start using the private headers in your applications, I will have to hunt you down.
-fast and -no-fast (Unix only)
Enables fast compilation of Qt, as opposed to slow compilation.
-no-gui (Unix only)
Disables building of any GUI part of Qt. Undocumented and unsupported.
-no-core (Unix only)
Disables building of QtCore and its dependencies. Undocumented and unsupported.

Environment variables (runtime)

Causes the Qt painting system to paint the updated region yellow for milliseconds before it does the actual painting. Trivia: the function that does this operation is called QWidgetBackingStore::showYellowThing in src/gui/painting/qwidgetbackingstore.cpp.
A factor to be used in multiplying the delivery speed of signals and slots, to aid in debugging signal-slot connections. Values > 1 will cause delivery to be slower.
Causes the Qt networking stack to open sockets using the security extensions proposed by RFC 3514 on systems that support it (currently only FreeBSD). See also QTBUG-18517.
Disables support for web servers returning the HTTP 418 status code. Meant for debugging only for broken servers.
Allows Qt to run on systems without a filesystem. On systems with a filesystem, this is useful to aid debugging applications that are meant to run on systems without file support.
Disables the Qt extensions to the Automotive segment. This enables only the Mobile segment extensions.
Enable an alternative memory allocation strategy that improves the chances for avoiding dereferencing dangling pointers.
This is variable has two meanings, depending on the system you're running. On the Power PC architecture, it disables the in-order execution of I/O. On some other systems, it will also disable catching of fatal system errors.
Disables Qt quirky behaviour compatibility mode, enables strict-conforming behaviour. This requires the compiler option -fkeep-programmers-inline.
Useful for debugging running Qt in out-of-memory situations.
Extreme memory conservation, implies QT_NO_FREE but conflicts with QT_NO_MEMORY.
Disable all Qt features (implies QT_NO_BUGS).
Enables QtConcurrent finishing tasks before the results are calculated.

Qt Creator options (runtime)

Disables the Qt Creator code indexer. Useful for low-powered or old workstations with not enough RAM.
Disables the Qt Creator code editor. Meant for specialists and hackers who don't need to edit code.
Causes the C++ code analyser to print some debugging information. Meant for debugging the analyser, but the information printed can be used to find out problems in the user's code, especially when the compiler error messages aren't very informative.
Causes the C++ code analyser to correct flaws and bugs in the user code, not just highlight them. Experimental feature.
Makes the C++ code analyser interpret all C++ source files as if they were C, disabling C++-specific keywords.
Makes the C++ code analyser interpret all C++ and C source files as if they were B. Experimental.


Pauses the WebKit 2 worker process on launch, allowing a debugger to be attached.
Pauses the WebKit 1 normal processing.
Enables WebKit compatibility for the gopher protocol.
Disables support for HTML 3 and above.

Blog Topics: