开发者

How can I load a external QML file in Qt Quick?

开发者 https://www.devze.com 2023-04-09 20:55 出处:网络
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 Q

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

精彩评论

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