Customizable message box



  • Hi,
    I want to display message box (modal) in my qml application that has custom graphical elements so its appearance is the same as the rest of my application. I need to customize buttons, text, colors, add some image in the message box etc.

    Standard MessageDialog QML Type is not good for me as I can't customize its appearance.

    What's the best way to achieve this? The application will run on Windows and Android.


  • Moderators

    Hi! Just use a QtQuick Window and make it modal; you can then customize whatever you want:

    import QtQuick 2.6
    import QtQuick.Controls 1.5
    import QtQuick.Window 2.2
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Button {
            anchors.bottom: contentItem.bottom
            text: "Show Dialog"
            onClicked: myDialog.visible = true
        }
    
        Window {
            id: myDialog
            visible: false
            flags: Qt.Dialog
            title: "My Dialog"
            color: "plum"
            Button {
                anchors.centerIn: parent
                onClicked: myDialog.visible = false
                text: "Hide"
            }
        }
    }
    

Log in to reply
 

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