在本教程建议我为每一个按钮
当然,你的意思是“为每个按钮类型”由不同.qml!?
启动第二个窗口:
// Main.qml
Window {
id: win
width: 640
height: 480
Button {
text: qsTr("Open")
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
onClicked: {
var factory = Qt.createComponent("Popup.qml");
factory.createObject(win);
}
}
}
// Popup.qml
Window {
height: 240
width: 320
title: qsTr("Popup")
visible: true
Text {
text: qsTr("Hello")
anchors.centerIn: parent
}
}
我阅读,我不得不做出这样的与QWidget的继承的类
不要混合QML和Qt窗口小部件模块,除非你是扩展/转换遗留系统,QML已被设计为替换Qt Widgets(在某些时候)。