Positioning in qml is incomplete
-
we can't create "Anchor Layout Example" in qml.
two problems:- without layout dont exist minimum, preferred, maximum width and height.
- with layout can't use anchors.
-
Are you saying you cannot make the example run?, it should work, provided you have used the correct data. If you use the resources from the following link (.pro, .cpp) https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/graphicsview/anchorlayout?h=5.14 it should just work.
Perhaps I misunderstand your question . . . ?
-
Are you saying you cannot make the example run?, it should work, provided you have used the correct data. If you use the resources from the following link (.pro, .cpp) https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/graphicsview/anchorlayout?h=5.14 it should just work.
Perhaps I misunderstand your question . . . ?
@Markkyboy no, this example make and run correctly.
can you write this example with qml to working like this? -
Okay, this is as close as I could get (but without anchoring methods);
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Layouts 1.3 import QtQuick.Controls 1.4 Window { visible: true width: 200; height: 120 title: qsTr("Anchor layout in QML") GridLayout { rows: 4 columns: 3 // row 1 Button { text: "A" } Button { text: "B" Layout.fillWidth: true Layout.columnSpan: 2 } // row 2 Button { text: "F" Layout.row: 2 Layout.preferredWidth: 40 } //row 3 Button { text: "G" Layout.row: 3 Layout.preferredWidth: 40 } // row2 Button { text: "C" Layout.row: 2 Layout.rowSpan: 2 Layout.column: 1 Layout.fillHeight: true } // row 4 Button { text: "D" Layout.fillWidth: true Layout.columnSpan: 2 Layout.row: 4 } Button { text: "E" Layout.row: 4 Layout.column: 2 } } }
-
Okay, this is as close as I could get (but without anchoring methods);
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Layouts 1.3 import QtQuick.Controls 1.4 Window { visible: true width: 200; height: 120 title: qsTr("Anchor layout in QML") GridLayout { rows: 4 columns: 3 // row 1 Button { text: "A" } Button { text: "B" Layout.fillWidth: true Layout.columnSpan: 2 } // row 2 Button { text: "F" Layout.row: 2 Layout.preferredWidth: 40 } //row 3 Button { text: "G" Layout.row: 3 Layout.preferredWidth: 40 } // row2 Button { text: "C" Layout.row: 2 Layout.rowSpan: 2 Layout.column: 1 Layout.fillHeight: true } // row 4 Button { text: "D" Layout.fillWidth: true Layout.columnSpan: 2 Layout.row: 4 } Button { text: "E" Layout.row: 4 Layout.column: 2 } } }
@Markkyboy thanks.
please change "Anchor Layout Example" form size and look at how the buttons size change.