Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt GUI internals - widget painting?

I've been using QT for a while now and I've been wondering about something regarding the way the GUI is painted in Windows.
Is it really painting all the buttons, edit boxes, combo-boxes, check-boxes, tabs etc' on its own using QPainter or is it somehow using the native widgets?

The fact that it can do custom styling and skinning suggests that it does in fact draw everything using QPainter but how can this kind of code possible be maintained? Did the Qt developers really reverse-engineer the entire functionality of the windowing system? isn't that somewhat wasteful?
Another evidence to this is that if I'm using Spy++ on a Qt gui then all the windows are showing with a class name equal to "QWidget". If it were using the native widgets shouldn't these be "BUTTON", "STATIC" etc'?

What about on other platforms? Is it doing the same in Max OSX as well?

like image 777
shoosh Avatar asked Dec 17 '22 08:12

shoosh


1 Answers

On Windows XP and Vista (except when the display settings set to Classic), the widget painting via QWindowsXPStyle and QWindowsVistaStyle actually use the low-level theme-specific drawing (uxtheme.dll) so that e.g. a push button looks like a native one. On older version of Windows, Qt emulates the widget painting through QWindowsStyle.

The situation is similar on Mac OS X, where QMacStyle relies on the Appearance Manager to delegate the low-level painting of the widgets.

For X11, usually Qt uses its own style painting and has certain styles which emulate some window system, e.g. QMotifStyle has similar look-and-like to Motif without actually loads and depends on Motif environment. However when running under GNOME, optionally Qt can use native Gtk+ theme via QGtkStyle.

like image 162
Ariya Hidayat Avatar answered Jan 01 '23 20:01

Ariya Hidayat