Qt GUI internal elements - drawing a widget?

I have been using QT for a while, and I was interested to learn about how the graphical interface is painted in Windows.
Does he really draw all the buttons, edit the fields, combo fields, checkboxes, tabs, etc. "Self" using QPainter or in some way using your own widgets?

The fact that he can do custom styling and skinning suggests that he really drew everything using a QPainter, but how can this type of code be supported? Have Qt developers really paid attention to all the functionality of the window system? Isn't that wasteful? Another proof of this is that if I use Spy ++ in Qt gui, then all windows show with the class name equal to "QWidget". If they use their own widgets, should they not be "BUTTON", "STATIC", etc. ??

How about on other platforms? Does it do the same in Max OSX?

+4
source share
3 answers

In Windows XP and Vista (except when the display settings are set to "Classic"), drawing a widget through QWindowsXPStyle and QWindowsVistaStyle actually use a low-level drawing for the theme (uxtheme.dll), so that, for example, the button looks like a native one. In the old version of Windows, Qt emulates widget painting through QWindowsStyle .

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

For X11, Qt usually uses its own style manner and has certain styles that emulate some window system, for example. QMotifStyle has a similar view to Motive without actual loads and depends on the Motif environment. However, when working under GNOME, perhaps Qt can use its own Gtk + theme through QGtkStyle .

+7
source

The QWindowsXPStyle documentation has this to say:

"Warning: this style is only available on the Windows XP platform because it uses the Windows XP style engine.

The Qt Wikipedia page has this to say:

"Using native user interface APIs

Qt is used to emulate the appearance of its intended platforms, which sometimes led to slight discrepancies when this emulation was imperfect. Recent versions of Qt use their own APIs from various platforms to create Qt controls and therefore do not suffer from such problems. [24] (See also wxWidgets, which uses native APIs for most widget functions.)

+4
source

Qt really paints all the widgets themselves (regardless of whether it uses the platform API or the raw GDI / X / etc). If he uses his own widgets (for example, wxWindows), it would be almost impossible to connect to the style to change even the smallest details, not to mention using a ready-made widget to add custom functions on top.

+1
source

All Articles