簡體   English   中英

當我在qml文件中添加矩形對象時會發生什么?

[英]What happens when I add a rectangle object in qml file?

當我添加一個矩形后會發生什么

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

}

在QML文件中?

是什么引起的,並繪制了一個藍色矩形? 機制是什么? 你能建議我讀書嗎? 謝謝

一般來說:

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

將QGraphicsRectItem鍵入assistant-qt4(主要的qt文檔助手),然后意識到您的qml代碼“ Rectangle”最終將創建一個,您就會感到溫暖。 目前,Qt4 QtQuick實現是QGraphicsView / QGraphicsScene的精簡抽象。 如上所述,步驟相同:

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

這些類的文檔非常好,一旦您了解了它們的原理,您就可以繼續研究它們向QDeclarative *等的發展。不幸的是,后者的文檔在某些細節上有些欠缺,但總體上還是很有用的。 當然,還有更多的東西-但是一旦您意識到QtQuick的演變源自QGraphicsView / -Scene類,則其他一切都變得更加合乎邏輯。 然后,瞥一眼源代碼(缺少文檔)會使您感覺更加有針對性-因為您已經了解了解析后的標記最終將如何融合到在QGraphicsScene(QDeclarativeView,..)中創建的QGraphicsItem的蜜蜂中。

祝好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM