Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to make



  • Hello,

    I'd like to align two buttons in RowLayout, but I've got an error message: "Unable to assign [undefined] to int" when I am trying to align to the right first button in a row.

    import QtQuick 2.3
    import QtQuick.Controls 1.2
    import QtQuick.Dialogs 1.2
    import QtQuick.Layouts 1.1
    import QtQuick.Window 2.0
    import "qrc:/qml/public"
    import "../public"
    
    Item {
        id: root
        width: 580
        height: 400
        SystemPalette { id: palette }
        clip: true
    
        property string confirmationMessage: "Do you confirm?"
        property string buttonTextYes: "Yes"
        property string buttonTextNo: "No"
        property int rowHight: 50
    
        Dialog {
            id: confirmationDialog
            modality:   Qt.WindowModal
            title: "Confirmation Dialog"
            onButtonClicked: console.log("clicked button " + clickedButton)
            onYes: clickedButton === StandardButton.Yes ? console.log("Yeessss!!") : console.log("Yes, now and always")
            onNo: clickedButton === StandardButton.No ? console.log("Oh No.") : console.log("No, no, a thousand times no!")
    
            contentItem:
                RowLayout
                {
                    spacing: 6
                    Rectangle
                    {
                        id: textRect
    
                        Layout.alignment: Qt.AlignCenter
                        Layout.preferredWidth: parent.width
                        Layout.preferredHeight: rowHight
                        Text
                        {
                            id: confirmationText
                            text: confirmationMessage
                        }
                    }
    
    
                    RowLayout
                    {
                        id: buttonRowLayout
                        Layout.alignment: Qt.AlignBottom
                        Layout.fillHeight: true
                        Layout.preferredWidth: parent.width
                        Layout.preferredHeight: parent.height
    
                        Tqmlc_TextButton
                        {
                            Layout.alignment: Qt.AlignRight
                            text: buttonTextYes
                            color: "blue"
                        }
                        Tqmlc_TextButton
                        {
                            Layout.alignment: Qt.AlignLeftRight
                            text: buttonTextNo
                            color: "blue"
                        }
                    }
                }
    
    
            Label {
                text: confirmationMessage
            }
        }
    
        Rectangle {
            id: bottomBar
            anchors {
                left: parent.left
                right: parent.right
                bottom: parent.bottom
            }
            height: confirmationDialogButton.height * 1.2
            color: Qt.darker(palette.window, 1.1)
            border.color: Qt.darker(palette.window, 1.3)
            Row {
                id: confirmationDialogButton
                spacing: 6
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 12
                width: parent.width
                Button {
                    text: "Confirmation dialog"
                    anchors.verticalCenter: parent.verticalCenter
                    onClicked: confirmationDialog.open()
                }
            }
        }
    
    }
    


  • Hi
    In your 2nd Tqmlc_TextButton you have

    @OpenCoder said in How to make:

    Tqmlc_TextButton
    {
    Layout.alignment: Qt.AlignLeftRight

    sould be Qt.AlignLeft


Log in to reply