Qt Creator: how to create Qt6 project? - qt

I have installed Qt 6.0.3 and 6.1.0.
And I want to create Qt 6 Quick project.
I start Qt Creator, click "New", "Qt Quick Application - Empty", "Choose...".
Then I type the name of my project and click "Next".
On the "Build System" step I select any build system(qmake, CMake or QBS, it does not affect the next step) and click "Next".
On the next step "Details" there is a drop-down with a list of available Qt versions. But it does not contain Qt 6!
How to create Qt 6 Qt Quick project?

Latest Qt Creator's (4.14.2 at the time of answering) new project assistant does not provide the option to require Qt 6 as a minimal version yet. There is an open bug about the missing feature in Qt Bug Tracker: New project assistant: no minimal Qt version >= 6.0
However, as #JarMan already commented you actually configure your project for specific kit and selecting e.g. Qt 6.0.3 kit means that you configure and build your application against that Qt version.
In fact, minimal Qt version selection in Qt Quick application wizard affects versions of the QML import statements used in generated QML files. E.g. selecting Qt 5.12 as minimal version means that you get import QtQuick 2.12 and import QtQuick.Window 2.12 written to your main.qml. And selecting Qt 5.15 as minimal version means getting import QtQuick 2.15 and import QtQuick.Window 2.15, and so on.
In Qt 6 version numbers may be omitted from imports in QML. If the version is omitted, the latest version will be used.
Most probably it means that when Qt Creator starts supporting Qt 6 as minimal version respective generated import statements will be import QtQuick and import QtQuick.Window.
You can actually edit your generated Qt Quick application so that you manually remove version numbers from import statements if you wish. It will turn your application to minimal Qt6 application because that application cannot be built with Qt5 kits anymore.

Related

Qt Creator -> Qt Quick Application (QML) -> Design Tab -> Missing "Window"

In Design tab the "Window" is missing.
When I click the Design tab -> pop up three windows. three windows
After I close one -> disappear all of them.window title
It doesn't work when I try to drag and drop basic component's...
I reinstall the Qt Creator but the same thing...
Have a look at the following bugreport https://bugreports.qt.io/browse/QTCREATORBUG-26486
Here are some key points from the comments.
Three things you shouldn't have done:
Enable the QmlDesigner plugin (isn't officially supported by Qt Creator anymore, you can use Qt Design Studio)
Open a non-.ui.qml file in QmlDesigner
Open a file with a QtQuick.Window root element, which is not fully endorsed in QmlDesigner.
Support for Qt 5.15 requires a "kit" with a qml2puppet for Qt 5.15.
This setup is only properly supported and tested in Qt Design Studio.
If you use Qt Creator the puppet will be always built with the same Qt
version as Qt Creator.
QtCreator states are kept in the following locations:
Windows: %APPDATA%\QtProject and %LOCALAPPDATA%\QtProject\QtCreator
Linux: $HOME/.config/QtProject
macOS: $HOME/.config/QtProject
Please review those locations and backup/rename/clean up.
You should find this restores your Qt Creator to 'factory' conditions.

How to find the QtQuick UI File template in the Qt Creator?

I cannot find the QtQuick UI File template on the Qt Creator templates screen. How can I solve this problem? I have Qt 6.3.1
They just changed the place of it from QtCreator to QtDesign Studio. If you are using Linux you can find it in
"Qt installed Folder"/Tools/QtDesignStudio/bin/qtdesignstudio
It might be like the picture.

import Qt5Compat.GraphicalEffects: QML module not found

I am on Arch Linux and I am trying to use PySide6 and QT6 in my project since I will need to be able to use singleton qml objects and PySide2 doesn't seem to support the registration of singleton qml objects. My project uses ColorOverlays and DropShadows, so I will need GraphicalEffects support. However, according to the doc pages, these aren't supported by Qt6 and require a compatibility module, Qt5Compat.GraphicalEffects to be supported.
I am trying to import Qt5Compat.GraphicalEffects into my QML code via the import statement below:
import Qt5Compat.GraphicalEffects
However, when I add this to my project's QML in QT Creator, I am getting the error: "QML module not found."
Here are some things I have tried in order to remedy this issue:
Installed QT using the installer from the website.
Installed Qt6/5 via pacman.
Installed the qt6-5compat package from the AUR.
Installed qt6/5-base from the AUR.
Googling the issue.
How can I fix this issue with importing Qt5Compat.GraphicalEffects?
EDIT:
I am using Python and PySide6 for my backend code, but I am writing the front-end in QML, which is where I am having my issue.
Here could be the solution for the problem.
From the main directory "QT" you need to take the Qt5Compad module. This must be added to the development environment.
It works with Pyside6 and PyQT6.
Here is a better description: QT6.4 QML PYTHON module "Qt5Compat.GraphicalEffects" is not installed
You have to keep in mind that PySide2 is a binding of Qt5 and PySide6 is that of Qt6.
If you want to use ColorOverlay or DropShadow with pyside2 then you should follow the Qt5 documentation that says you should use import QtGraphicalEffects 1.15.
If instead you want to use it in pyside6 it has moved those components to the Qt5Compat module so you should use: import Qt5Compat.GraphicalEffects.
So the way to import will depend on whether you are using PySide2 (Qt5) or PySide6 (Qt6).
Note: QtCreator does not have many capabilities so many times it will throw false positives since it is not able to understand PySide. Unfortunately they have not given it "much affection" so it is not optimized to work with python obtaining that type of warnings. So just obviate the warning.

Importing Qt Studio Project in a Qt Creator QML app

I have created a hello world project in Qt Design Studio. Now I need to import QtDS project tree/directory in QtQuick qml app.
The official documentation about this topic is in doc.qt.io/qtdesignstudio/quick-converting-ui-projects. Assuming still this cannot work for you. You can check this post in the Qt forum: how-to-use-qmlproject-ui-qml-forms-from-design-studio-in-qt-creator-pro-project.
So in order to resume the information:
Set all your *.ui.qml files from Qt DS project to a separate *qrc.
Import the new *qrc into your Main Qt Project.

How can I know which Qt quick version in my system before importing that?

By qVersion() I will get the Qt version as 5.13.1
But in QML I use import QtQuick 2.12. How to get the QtQuick version C++/QML (2.12)?
I do not know of any way to "print the QtQuick version" (as per your comment on your question). However, reading the docs it seems that it is just a 1:1 mapping between the Qt version and the QtQuick version.
This Qt forum post appears to confirm that post:
Every new Qt release gets a new QtQuick version. It's a 1 to 1 mapping so far: Qt 5.x has QtQuick 2.x (so, Qt 5.4 has QtQuick 2.4). You can check that by opening the documentation for - for example - Rectangle or Item.
Here's the corresponding documentation that shows the mapping of the Qt version and the QtQuick(Controls) version: https://doc.qt.io/qt-5/qtquickcontrols-index.html
From that it would appear that you need to use/import QtQuick 2.13 when you're using Qt 5.13.

Resources