How do I show a message box with Qt Quick Controls?

Timmmm picture Timmmm · Sep 13, 2013 · Viewed 19.9k times · Source

What is the equivalent of QMessageBox::information() when one wishes to write a QML application using Qt Quick Controls?

Answer

Zmey picture Zmey · Dec 18, 2013

In Qt 5.2 there is MessageDialog:

http://doc.qt.io/qt-5/qml-qtquick-dialogs-messagedialog.html

import QtQuick 2.2
import QtQuick.Dialogs 1.1

MessageDialog {
    id: messageDialog
    title: "May I have your attention please"
    text: "It's so cool that you are using Qt Quick."
    onAccepted: {
        console.log("And of course you could only agree.")
        Qt.quit()
    }
    Component.onCompleted: visible = true
}