gpt4 book ai didi

c++ - Qt 如何绘制它的 GUI 组件(基本思路)?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:29:24 25 4
gpt4 key购买 nike

当我浏览 Qt 的源代码时,我没有发现它实际上是如何绘制 GUI 组件的,但我知道它使用 OpenGL。

我想知道像 Qt 这样的 GUI 库如何绘制其 GUI 组件(例如:QPushButton、QWidget)?

任何人都可以帮助我提出一个基本想法吗?

最佳答案

在 Qt 项目站点中:

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.

谢谢。

关于c++ - Qt 如何绘制它的 GUI 组件(基本思路)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24584189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com