Important: Please read the Qt Code of Conduct -

Figure with editable input fields for entering dimensions

  • I want to have such a figure with editable input fields to enter the dimensions:

    Figure with editable input fields for dimensions

    Changing the input fields will cause the figure to readjust according to newly entered dimensions.


    Does QML have any feature which might help with implementing the above, which I might be missing?


    Sometimes the shapes are not rectangles:

    Non-rectangle shape

  • Moderators

    You have TextInputs or editable spinboxes where you just (property)bind the value to the related value of the shape?


    import QtQuick 2.12
    import QtQuick.Controls 2.12
    import QtQuick.Window 2.2
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        color: "white"
        id: win
            anchors.centerIn: parent
            color: "lightblue"
            width: 200
            height: 250
        TextInput {
            anchors.right: shape.left
            anchors.verticalCenter: shape.verticalCenter
            width: 200
            text: shape.height
            onTextChanged: shape.height = text
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignRight
            anchors.horizontalCenter: shape.horizontalCenter
            width: shape.width
            height: contentHeight
            text: shape.width
            onTextChanged: shape.width = text
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter

Log in to reply