Skip to content

Commit

Permalink
qtquick: Added example for min-size support
Browse files Browse the repository at this point in the history
Started documenting it.
There's seems to be lots of improvements to do.

For issue #262
  • Loading branch information
iamsergio committed Jan 23, 2024
1 parent 9c73559 commit d55fadf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- [Advanced Usage]()
- [Custom Behaviour](custom_behaviour.md)
- [Custom Styling](custom_styling.md)
- [Min/Max sizing](min_max_sizing.md)
- [Public and Private API](private_api.md)
---
- [For Developers]()
Expand Down
16 changes: 16 additions & 0 deletions docs/book/src/min_max_sizing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# min/max sizing

## QtWidgets

KDDW will honour min/max constraints set on the guest widget.<br>
You can run the example `qtwidgets_dockwidgets -g` to see the max-size in action.<br>
Setting the constraints directly on `DockWidget` is not advised.

## QtQuick

Minimum sizes are supported but not maximum sizes.<br>
There's no public API to set the minimum sizes, but you can set a special property called `kddockwidgets_min_size`
on your guest item.<br>
For an example, run the `qtquick_dockwidgets` sample executable, then go to "File" menu, and chose `New widget with min-size`.

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.
27 changes: 27 additions & 0 deletions examples/qtquick/dockwidgets/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,32 @@ ApplicationWindow {
}
}

Action {
text: qsTr("Create widget with min-size")
onTriggered: {
/// Do not use random uuids if you're planing to use layout save/restore!
/// Using them here for convenience of the exercise
var uniqueName = _kddwHelpers.generateUuid();

var code = `import com.kdab.dockwidgets 2.0 as KDDW;
import QtQuick 2.6;
KDDW.DockWidget {
uniqueName: "${uniqueName}";
title: "min-size=" + guest.kddockwidgets_min_size
Rectangle {
id: guest
property var kddockwidgets_min_size: Qt.size(800, 200)
// property var kddockwidgets_max_size: Qt.size(800, 400) Not yet supported
color: "#85baa1";
anchors.fill: parent;
}
}`;

var newDW = Qt.createQmlObject(code, root);
newDW.open();
}
}

Action {
text: qsTr("Close All")
onTriggered: {
Expand All @@ -82,6 +108,7 @@ ApplicationWindow {
}

KDDW.DockingArea {
id: root
anchors.fill: parent

// Each main layout needs a unique id
Expand Down

0 comments on commit d55fadf

Please sign in to comment.