QML文件中如何创建QML对象并打开:
一、正确的方法:
1)、创建qml对象:
ChannelAndCheckPointSet{
id:dlgChannelAndCheckPointSet
}
2)、使用对象打开窗口:
Button{
text: qsTr('拾取坐标');
id:button_0102;
width:60;
Layout.maximumWidth: 60;
Layout.minimumWidth: 60;
onClicked: {
dlgRedGreenPointSet.cid=camid;
dlgRedGreenPointSet.checkpointid='01';
dlgRedGreenPointSet.open();
}
}
二、不要使用下面的方法:
var caps = Qt.createComponent(‘RedGreenPointSet.qml’).createObject(dialog);
1、打开速度很慢;
2、窗口会脱离主窗口;