註冊QML型別

2021-08-08 08:50:59 字數 330 閱讀 4369

使用qmlregistertype可以將其註冊到qml型別系統。

qmlregistertype函式需要乙個合適的命名空間和乙個版本號;

如下面的**將message類註冊到命名空間org.qter.messaging,版本號為1.0

//message有2個屬性author、creationdate

qmlregistertype("com.mycompany.messaging",1,0,"message");

//註冊成功之後,就可以在qml中宣告和建立這個型別的物件,並使用其屬性。

message

QML基礎 QML物件型別介紹

用了n年的qwidget,因為專案需求而開始學習qml做一些動態的介面,下面開始記錄學習qml的新路歷程。注 學習有誤的望指點一二,不喜勿噴!用語法術語來說,qml物件型別是一種可以用來宣告物件的方法,方法是指定型別每次,後跟一組包含該物件屬性的花括號。這與基本型別不同,基本型別不能以該方式使用。例...

QML型別說明 AnimatedSprite

animatedsprite importstatement import qtquick2.2 inherits item properties currentframe int framecount int frameduration int frameheight int framerate ...

QML型別說明 AudioSample

audiosample importstatement import qtaudioengine1.0 since qt 5.0 inherits item properties loaded bool name string preloaded bool signals loadedchanged...