Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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.

    Question

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

    Update

    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?


    example:

    import QtQuick 2.12
    import QtQuick.Controls 2.12
    import QtQuick.Window 2.2
    
    Window
    {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        color: "white"
        id: win
    
        Rectangle{
            id:shape
            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
        }
        TextInput{
            anchors.top: shape.bottom
            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