qtquick: Move the "Another" button into the main window

This commit is contained in:
Sergio Martins
2021-04-05 14:09:59 +01:00
parent 1026abbbf4
commit 0f09ba717f
2 changed files with 25 additions and 30 deletions

View File

@@ -10,38 +10,10 @@
*/
import QtQuick 2.9
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 1.0 as KDDW
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
KDDW.DockWidget {
id: another
uniqueName: "another1"
source: ":/Another.qml"
}
Button {
text: "Toggle Another"
anchors {
bottom: parent.bottom
left: parent.left
margins: 5
}
onClicked: {
if (another.dockWidget.visible) {
another.dockWidget.close();
} else {
another.dockWidget.show();
}
}
}
}

View File

@@ -10,6 +10,7 @@
*/
import QtQuick 2.6
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 1.0 as KDDW
KDDW.MainWindow {
@@ -18,14 +19,36 @@ KDDW.MainWindow {
Repeater {
model: 3
KDDW.DockWidget {
id: another
uniqueName: "fromRepeater-" + index
source: ":/Another.qml"
}
}
KDDW.DockWidget {
id: dock4
uniqueName: "dock4"
source: ":/Another.qml"
}
Button {
text: "Toggle Another"
anchors {
bottom: parent.bottom
left: parent.left
margins: 5
}
z: 10
onClicked: {
if (another.dockWidget.visible) {
another.dockWidget.close();
} else {
another.dockWidget.show();
}
}
}
Component.onCompleted: {
root.init("MyWindowName-1");
}
}