qtqmlqtquick2qtquickcontrols2

What is the QMessageBox::aboutQt equivalent in QML?


Is there an equivalent of QMessageBox::aboutQt which can be used in QML? I didn't find anything suitable in the QtQuick.Dialogs module (https://doc.qt.io/qt-5/qtquickdialogs-index.html).


Solution

  • The closest match of QMessageBox::about with QML would be MessageDialog setup like this:

    import QtQuick 2.2
    import QtQuick.Dialogs 1.1
    
    MessageDialog {
        title: "Your title"
        icon: StandardIcon.Information
        text: "Your text"
        standardButtons: StandardButton.Ok
        Component.onCompleted: visible = true
    }
    

    As for QMessageBox::aboutQt, according to this topic, in the Qt forum, there is no QML equivalent and it is better to invoke qApp->aboutQt:

    reading the docs seems there's no aboutQt for QML.

    probably better to invoke standard qApp->aboutQt from C++ class.