How can Qt draw its GUI components (main idea)?

When I looked at the Qt source code, I did not find how it actually draws a GUI component, but I know that it uses OpenGL.

I want to know how a GUI library like Qt draws its GUI components (ex: QPushButton, QWidget)?

Can someone help me with a basic idea?

+5
source share
1 answer

On the Qt-project website:

Qt draws QtWidgets using a QPainter, which uses a (usually) raster engine to draw content. It does not use calls on the native OS, with the exception of a few exceptions (for example, a file dialog box that can be drawn either initially or using QtWidgets).

QtQuick is colored using a script, therefore OpenGL. In addition, there is no native OS.

I think that you either misunderstood (there are several meanings of the word "native" in the calculation) postoffflow post, or your source of information is wrong.

OK, and then, to be clear: "native" Ive meant using your own OS commands, for example, the wxWidgets library: asking the OS to draw its own scroll bar or combo box, etc. Qt does not. It displays all the widgets themselves and only tries to simulate the appearance of the OS on which it works.

But, obviously, something like calling your own OS happens deep inside to actually draw some pixels on the screen and open your own window container. But this is usually not important for high-level user interface developers.

You have a clear choice: whether to draw a graphics processor or a graphics processor: widgets can use different drawing methods (native, raster, OpenGL, see here for more details! [Qt-project.org]), and the user has a choice that need to use. Most people do not use this because the default settings work well.

Thanks.

+4
source

All Articles