Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Create a MessageDialog using Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Create a MessageDialog using Qt Creator

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 332 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qcoderpro
    wrote on last edited by qcoderpro
    #1

    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! :|

    JKSHJ 1 Reply Last reply
    0
    • Q qcoderpro

      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! :|

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @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.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      Q 1 Reply Last reply
      2
      • JKSHJ JKSH

        @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.

        Q Offline
        Q Offline
        qcoderpro
        wrote on last edited by
        #3

        @JKSH

        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! :|

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved