Skip to content

Commit d55fadf

Browse files
committed
qtquick: Added example for min-size support
Started documenting it. There's seems to be lots of improvements to do. For issue #262
1 parent 9c73559 commit d55fadf

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

docs/book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- [Advanced Usage]()
3636
- [Custom Behaviour](custom_behaviour.md)
3737
- [Custom Styling](custom_styling.md)
38+
- [Min/Max sizing](min_max_sizing.md)
3839
- [Public and Private API](private_api.md)
3940
---
4041
- [For Developers]()

docs/book/src/min_max_sizing.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# min/max sizing
2+
3+
## QtWidgets
4+
5+
KDDW will honour min/max constraints set on the guest widget.<br>
6+
You can run the example `qtwidgets_dockwidgets -g` to see the max-size in action.<br>
7+
Setting the constraints directly on `DockWidget` is not advised.
8+
9+
## QtQuick
10+
11+
Minimum sizes are supported but not maximum sizes.<br>
12+
There's no public API to set the minimum sizes, but you can set a special property called `kddockwidgets_min_size`
13+
on your guest item.<br>
14+
For an example, run the `qtquick_dockwidgets` sample executable, then go to "File" menu, and chose `New widget with min-size`.
15+
16+
Note that while KDDW floating windows and docked widgets will honour the min size, the main window itself won't, as that's an item completely controlled by the user. Maybe we could expose the main window's KDDW layout min/max size, then users could use that to calculate the main window's min/max.

examples/qtquick/dockwidgets/main.qml

+27
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,32 @@ ApplicationWindow {
5757
}
5858
}
5959

60+
Action {
61+
text: qsTr("Create widget with min-size")
62+
onTriggered: {
63+
/// Do not use random uuids if you're planing to use layout save/restore!
64+
/// Using them here for convenience of the exercise
65+
var uniqueName = _kddwHelpers.generateUuid();
66+
67+
var code = `import com.kdab.dockwidgets 2.0 as KDDW;
68+
import QtQuick 2.6;
69+
KDDW.DockWidget {
70+
uniqueName: "${uniqueName}";
71+
title: "min-size=" + guest.kddockwidgets_min_size
72+
Rectangle {
73+
id: guest
74+
property var kddockwidgets_min_size: Qt.size(800, 200)
75+
// property var kddockwidgets_max_size: Qt.size(800, 400) Not yet supported
76+
color: "#85baa1";
77+
anchors.fill: parent;
78+
}
79+
}`;
80+
81+
var newDW = Qt.createQmlObject(code, root);
82+
newDW.open();
83+
}
84+
}
85+
6086
Action {
6187
text: qsTr("Close All")
6288
onTriggered: {
@@ -82,6 +108,7 @@ ApplicationWindow {
82108
}
83109

84110
KDDW.DockingArea {
111+
id: root
85112
anchors.fill: parent
86113

87114
// Each main layout needs a unique id

0 commit comments

Comments
 (0)