K
K
kabanov212018-07-10 09:30:50
QML
kabanov21, 2018-07-10 09:30:50

How in GridLayout (PyQt5) to make it possible to resize cells with the mouse?

GridLayout {
   id: gridLayout
   columns: 4
   Label {
   }
 
   TextField {
      Layout.columnSpan: 3
   }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
4
4rtzel, 2018-07-10
@4rtzel

It seems to me that this can not be done using GridLayout'a (or it will be quite difficult). Perhaps TableView or SplitView would be better suited for this.
A quick, hacky solution with SplitView:

import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 1.4

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    SplitView {
        anchors.fill: parent
        orientation: Qt.Vertical
        SplitView {
            anchors.left: parent.left
            anchors.right: parent.right
            height: parent.height / 2
            orientation: Qt.Horizontal

            Rectangle {
                id: rect1
                width: parent.width / 2
                onWidthChanged: {rect3.width = width}
                color: "lightblue"
            }
            Rectangle {
                id: rect2
                width: parent.width / 2
                onWidthChanged: {rect4.width = width}
                color: "lightgreen"
            }
        }
        SplitView {
            anchors.left: parent.left
            anchors.right: parent.right
            height: parent.height / 2
            orientation: Qt.Horizontal

            Rectangle {
                id: rect3
                width: parent.width / 2
                onWidthChanged: {rect1.width = width}
                color: "blue"
            }
            Rectangle {
                id: rect4
                width: parent.width / 2
                onWidthChanged: {rect2.width = width}
                color: "green"
            }
        }
    }
}

5b45193a1184d343332859.gif

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question