1

I am trying to test some QT Dialogs (I am a new bee on QT btw) and I keep getting this message:

"qrc:/main.qml:3:1: module "QtQuick.Dialogs" version 1.3 is not installed"

I looked at this thread:

module "QtQuick.Dialogs" version 1.3 is not installed

Then, I tried to go back to 1.2 but did not resolve.

I am using:

Qt Creator 8.0.0 Based on Qt 6.3.1 (MSVC 2019, x86_64) Built on Jul 19 2022 08:06:48

Update:

I believe my problem is the CMakeLists.txt, this is what I have there:

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick QuickControls2)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick QuickControls2)
set(PROJECT_SOURCES
    main.cpp
    qml.qrc)

a bunch of stuff (I use the autogenerated CMakeLists.txt) then

 target_link_libraries(color_dialog
      PRIVATE Qt${QT_VERSION_MAJOR}::Core
      Qt${QT_VERSION_MAJOR}::Quick
      Qt${QT_VERSION_MAJOR}::QuickControls2)

then the code, which I doubt is the problem:

import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Dialogs 1.3
import QtQuick.Controls 2.5

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("ColorDialog Test")

    Column {
        spacing: 10
        anchors.centerIn: parent

        Button{
            text : "Pick a Color"
            anchors.horizontalCenter: parent.horizontalCenter
            onClicked: {
                colorDialogId.open()
            }
        }

        Rectangle{
            width: 300
            height: 300
            id : rectangleId
            border.color: "cornflowerblue"
            border.width: 4
            anchors.horizontalCenter: parent.horizontalCenter
        }

        ColorDialog{
            id : colorDialogId
            title: "Pick The Color"
            onAccepted: {
                console.log("onAccepted: "+ color)
                rectangleId.color = color
            }
        }
    }
}

How do I resolve this? What I am missing on my CMakeLists.txt?

thank you!

gmmo
  • 2,577
  • 3
  • 30
  • 56
  • No. It is still there: https://doc.qt.io/qt-6/qml-qtquick-dialogs-filedialog.html Try new syntax: `import QtQuick.Dialogs` If it doesn't work - please provide full minimal example. Because this import works for me for Qt 6.3.1. – Sergei Lebedev Aug 06 '22 at 08:34
  • @SergeyLebedev I added more info to my post. I believe my problem might be the CMakeLists.txt. do you see anything I might be missing? Changing to the new syntax gives me this error: "qrc:/main.qml:33:9: ColorDialog is not a type" thank you! – gmmo Aug 06 '22 at 15:55
  • Try to create new project with Qt Creator so it will provide sufficient CMakeLists.txt for you. I guess Qt Quick Application the one you want to choose and mind all the rest of parameters while going through the wizard. But what needs to be done for packaging and installation is a different matter and I see you do Windows so become familiar with windeployqt tool. – Alexander V Aug 12 '22 at 01:12
  • They simply changed the versioning scheme in Qt6 as documented [here](https://doc.qt.io/qt-6/qtquickcontrols-index.html#versions). Now it's the same as Qt version, so for Qt 6.3 try `import QtQuick.Dialogs 6.3`. Besides, `ColorDialog` was [removed](https://doc.qt.io/qt-6/qtquickdialogs-index.html) in Qt6 from `QtQuick.Dialogs` since its functionality was duplicated in [Qt.labs.platform](https://doc.qt.io/qt-6/qml-qt-labs-platform-colordialog.html). – absolute.madness Aug 12 '22 at 09:08
  • @absolute.madness I don't understand. I already tried import QtQuick.Dialogs 6.3 and it gives me the same error (qrc:/main.qml:33:9: ColorDialog is not a type) So, how do I use the Qt.labs.platform. New bee here as I mentioned. – gmmo Aug 12 '22 at 20:51
  • 2
    @gmmo `import Qt.labs.platform 1.0` (or simply `import Qt.labs.platform`) instead of your `import QtQuick.Dialogs 6.3` – absolute.madness Aug 12 '22 at 20:57

1 Answers1

0

Thanks @absolute.madness. The answer turned out to be just not available on Windows even when using QT Labs Plaform

enter image description here

enter image description here

gmmo
  • 2,577
  • 3
  • 30
  • 56
  • 1
    Is it really unavailable on Windows? I don't have access to Windows PC atm to check, but as I understood from the docs, it should fall back to non-native implementation on other platforms. Btw, when I said that `ColorDialog` is unavailable in `QtQuick.Dialogs`, it should be read as ["as of Qt 6.3"](https://doc.qt.io/qt-6.3/qtquick-dialogs-qmlmodule.html). In Qt 6.4 [it seems to be back](https://doc-snapshots.qt.io/qt6-dev/qml-qtquick-dialogs-colordialog.html) in `QtQuick.Dialogs`. – absolute.madness Aug 12 '22 at 22:10
  • @gmmo what about [QColorDialog](https://doc.qt.io/qt-6/qcolordialog.html)? did you access this class in windows? If `Yes` you can create that part in CPP and then add it to your qml. – Parisa.H.R Aug 14 '22 at 00:34