How set position for Dialog in Qt Quick Controls 2 ?



  • hi
    i want to use dialog in Qt Quick Controls 2 added in Qt 5.8, but for open dialog in center of page you must use x,y.
    Gallery Sample :

        Dialog {
            id: aboutDialog
            modal: true
            focus: true
            x: (window.width - width) / 2
            y: window.height / 6
            width: Math.min(window.width, window.height) / 3 * 2
            contentHeight: aboutColumn.height
    
            Column {
                id: aboutColumn
                spacing: 20
    
                Label {
                    text: "About"
                    font.bold: true
                }
    
                Label {
                    width: aboutDialog.availableWidth
                    text: "The Qt Quick Controls 2 module delivers the next generation user interface controls based on Qt Quick."
                    wrapMode: Label.Wrap
                    font.pixelSize: 12
                }
            }
        }
    

    i want to use ant way for opening dialog in center of page , have any property for this?
    thanks.



  • The coordinates are relative to the parent. You can set ApplicationWindow.overlay as a parent to use scene coordinates.

    Dialog {
        x: (window.width - width) / 2
        y: (window.height - height) / 2
        parent: ApplicationWindow.overlay
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.