当我在 qml 文件中添加矩形对象时会发生什么?

发布于 2024-11-28 00:50:25 字数 172 浏览 0 评论 0原文

添加一个矩形时,后面会发生什么

Rectangle{
 width:40
 heigh: 40
 color:"blue"

}

当我在 qml 文件中

?什么调用什么并且绘制了一个蓝色矩形? 机制是什么?你能推荐一些读的东西吗,我找不到。 谢谢

What happens behind, when i add a rectangle

Rectangle{
 width:40
 heigh: 40
 color:"blue"

}

in a qml file?

What invokes what and a blue rectangle has been drawn?
What is the mechanism? Can you advise something to read, i couldnot find.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

〆凄凉。 2024-12-05 00:50:25

一般来说:

 -> parse Qml code 
 -> create QDeclarativeItems
 -> add to QDeclerativeView's scene
 -> call items standard slot like onCreated()
 -> call the QDeclarativeItems paint method etc     

一旦你在assistant-qt4(主要的qt文档助手)中输入QGraphicsRectItem,你会感到肚子暖暖的,后来意识到你的qml代码“矩形”终于创建了一个。 Qt4 QtQuick 实现目前是 QGraphicsView/QGraphicsScene 的精简抽象。如上所述,步骤是相同的​​:

 -> create QGraphicsItems
 -> add to QGraphicsView's scene 
 -> call QGraphicsItem paint method etc

这些类都有很好的文档记录,一旦您了解了它们的原理,您就可以继续研究它们向 QDeclarative* 等的演变。不幸的是,后者的文档在某些细节上有些缺乏,但总体来说非常有用。当然,还有更多内容 - 但一旦您意识到源自 QGraphicsView/-Scene 类的 QtQuick 演变,其他一切都更加合乎逻辑。然后,瞥一眼源代码(缺少文档)会让您感觉更有针对性 - 因为您知道解析的标记如何最终收敛到 QGraphicsScene 中创建的 QGraphicsItem(QDeclarativeView,..)。

祝你好运!

In general:

 -> parse Qml code 
 -> create QDeclarativeItems
 -> add to QDeclerativeView's scene
 -> call items standard slot like onCreated()
 -> call the QDeclarativeItems paint method etc     

You will get a warm belly feeling once you type QGraphicsRectItem into assistant-qt4 (the primary qt documentation assistant) and later realize that your qml code "Rectangle" is finally creating one. The Qt4 QtQuick implementation is currently a thin abstraction of QGraphicsView/QGraphicsScene. As above, the steps are the same:

 -> create QGraphicsItems
 -> add to QGraphicsView's scene 
 -> call QGraphicsItem paint method etc

These classes are exceptionally well documented, and once you understand their principle you are ready to go forward and study their evolution to QDeclarative* etc. Unfortunately the documentation of the latter is somewhat lacking in certain details, but overall very useful. Surely, there is more to it - but once your realize the QtQuick evolution originating from QGraphicsView/-Scene classes, everything else is much more logical. Then, a glimpse into the source code (where documentation was lacking) will make you feel much more oriented - as you have an idea how the parsed markup is finally converging into QGraphicsItem's beeing created in your QGraphicsScene (QDeclarativeView,..).

Good Luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文