How does Qt draw its GUI Components ( Basic Idea )?

前端 未结 1 1638
伪装坚强ぢ
伪装坚强ぢ 2021-01-18 07:32

When I browsed the source code of Qt I didn\'t find how it actually draws a GUI component, but I know it uses OpenGL.

I want to know how does a GUI library like Qt d

相关标签:
1条回答
  • 2021-01-18 08:03

    In Qt-project site :

    Qt is painting QtWidgets using QPainter, which uses (usually) the raster engine to draw the content. It is not using native OS calls, apart from few exceptions (file dialog, for example, which can be drawn either natively or using QtWidgets).

    QtQuick is painted using scenegraph, so OpenGL. Also, no native OS calls here.

    I think you either misunderstood (there are several meanings of the word “native” in computing) the stackoverflow post, or your information source is wrong.

    OK, then to be clear: by “native” I’ve meant using native OS controlls, like wxWidgets library does: asking the OS to draw native scroll bar, or combo box, etc. Qt does not do this. It paints all the widgets itself, and only tries to mimick the looks of the OS it is running on.

    But obviously, some kind of native OS calling is happening deep inside, in order to actually draw some pixels on the screen, and open native window container. But that is usually not important at all to high level UI developers.

    You have a clear choice whether the widget should be drawn by the CPU or the GPU: widgets can use different painting methods (native, raster, OpenGL, for more see here! [qt-project.org]), and the user has choice which one should be utilised. Most people do not use that, though, because the default settings work well.

    Thanks.

    0 讨论(0)
提交回复
热议问题