据我了解,QtQuick中没有可停靠容器的内置功能。我找到了一些添加了此资源的资源,但是我在确定选择哪种方法时遇到了麻烦。
https://developer.blackberry.com/native/documentation/dev/custom_components/index.html
如何从ApplicationWindow QML文件获取QMainWindow以允许将QDockWidget与QML文件一起使用
有人可以推荐一种方法(最好是一种库)来将对接添加到QtQuick吗?
我找到了一种解决方案,该解决方案可与多个窗口配合使用,从而将小部件从主窗口(对接状态)移动到新窗口(非对接状态)。
希望这里对其他人有用是一个完整的示例:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.Window 2.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Window {
width: 100;
height: 100;
visible: false;
id: wnd
Rectangle {
id: greenRect
anchors.fill: parent
}
onClosing: {
blueRect.state = "docked"
}
}
Item {
width: 200; height: 100
Rectangle {
id: redRect
anchors.fill: parent
}
Rectangle {
id: blueRect
width: 50; height: 50
x: 10; y: 10;
color: "blue"
states: [
State {
name: "undocked"
ParentChange { target: blueRect; parent: greenRect; x: 10; y: 10 }
},
State {
name: "docked"
ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 }
}
]
MouseArea {
anchors.fill: parent;
onClicked: {
blueRect.state = "undocked"
wnd.visible = true
}
}
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句