Create a MessageDialog using Qt Creator
-
I want to test this example: https://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 }
So created a Qt 5.15 Qt Quick project called QML_4 and tested that:
import QtQuick 2.15 import QtQuick.Dialogs 1.1 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") 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 } }
And I get this error: qrc:/QML_4/main.qml:2:1: module "QtQuick.Dialogs" version 1.1 is not installed
Up to know, I have tested making use of a MessageDialog in various QtQuick projects with qmake or CMake build system, Qt 6 or Qt 5 version of the Qt, and so forth. Yet it's not possible to use such a simple element in such a simple project using Qt Creator 6! :|
-
I want to test this example: https://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 }
So created a Qt 5.15 Qt Quick project called QML_4 and tested that:
import QtQuick 2.15 import QtQuick.Dialogs 1.1 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") 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 } }
And I get this error: qrc:/QML_4/main.qml:2:1: module "QtQuick.Dialogs" version 1.1 is not installed
Up to know, I have tested making use of a MessageDialog in various QtQuick projects with qmake or CMake build system, Qt 6 or Qt 5 version of the Qt, and so forth. Yet it's not possible to use such a simple element in such a simple project using Qt Creator 6! :|
@qcoderpro said in Create a MessageDialog using Qt Creator:
Up to know, I have tested making use of a MessageDialog in various QtQuick projects with qmake or CMake build system, Qt 6 or Qt 5 version of the Qt, and so forth. Yet it's not possible to use such a simple element in such a simple project using Qt Creator 6! :|
https://doc.qt.io/qt-6/qml-qt-labs-platform-messagedialog.html
Try "import Qt.labs.platform 1.1" (version number only needed in Qt 5, not Qt 6) instead of "import QtQuick.Dialogs 1.1".
Note: This version of MessageDialog is a bit different from the one you linked.
-
@qcoderpro said in Create a MessageDialog using Qt Creator:
Up to know, I have tested making use of a MessageDialog in various QtQuick projects with qmake or CMake build system, Qt 6 or Qt 5 version of the Qt, and so forth. Yet it's not possible to use such a simple element in such a simple project using Qt Creator 6! :|
https://doc.qt.io/qt-6/qml-qt-labs-platform-messagedialog.html
Try "import Qt.labs.platform 1.1" (version number only needed in Qt 5, not Qt 6) instead of "import QtQuick.Dialogs 1.1".
Note: This version of MessageDialog is a bit different from the one you linked.
Try "import Qt.labs.platform 1.1" (version number only needed in Qt 5, not Qt 6) instead of "import QtQuick.Dialogs 1.1".
Thanks, it worked, but why do I need to import Qt.labs.platform 1.1 while the project is not of Qt 6 but Qt 5?
The second question about that part is that, while the project works, but Qt Creator 6 doesn't recognize the element and draws a red line under it!
Up to know, I guess Qt5 was better than the existing Qt6.Note: This version of MessageDialog is a bit different from the one you linked.
That version does not give the expected output. So you think why I'm downgrading to qmake and Qt 5 while I'm normally using Qt6 and CMake! :|