开发者

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
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜