From 5f130afa9f47ea46b37f2a24e6f4592861301211 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 17 Sep 2020 15:54:06 -0700 Subject: [PATCH] Responsive Container grid --- ResponsiveContainer.qml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ResponsiveContainer.qml diff --git a/ResponsiveContainer.qml b/ResponsiveContainer.qml new file mode 100644 index 0000000..7c9af55 --- /dev/null +++ b/ResponsiveContainer.qml @@ -0,0 +1,27 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.4 +import QtQuick.Controls.Material 2.0 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 1.4 + + +GridLayout { + id: root + + // have children ... control weather to stack or row them + // n * minWidth determin + property int minCellWidth: 500 + + + onWidthChanged: resizeCheck() + + function resizeCheck() { + if (width < children.length * minCellWidth) { + root.rows = -1 + root.columns = 1 + } else { + root.rows = 1 + root.columns = -1 + } + } +}