How can I load a external QML file in Qt Quick?
Ok like if I'm trying to make something like a menu for a simple game. How can I make it so that when the start button is clicked it 开发者_StackOverflow中文版loads a different QML file?
You can use Qt.createComponent() or Loader. For example:
import QtQuick 1.0
Item {
MyButton {
onClicked: loader.source = "MyGameFile.qml"
}
Loader {
id: loader
anchors.fill: parent
}
}
精彩评论