Importing Qt Studio Project in a Qt Creator QML app - qt

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.

Related

how to use .qmlproject .ui.qml forms from Design Studio in Qt Creator .pro project?

I'm involved in a project that has a designer working in Design Studio to develop .ui.qml forms (with related assets) and me, the developer, working on an existing Qt Creator .pro project. I would like to keep the two projects in separate repositories.
Would someone be so kind as to point to a tutorial that covers this? Or a wiki page? Or some other resource on the web that explains how to do what I want to do i.e. use the .ui.qml resources from the .qmlproject in the QtQuick QML files in my .pro project.
Thanks for any an all pointers.
----- update for more detail -----
I have 2 projects, named marge and patty. Patty is a .qmlproject that is being worked on by the designer in Qt Design Studio and contains the UI forms in .ui.qml files along with related graphic assets and themes, etc. It is in its own git repository. Marge, on the other hand, is the .pro application that I'm developing in Qt Creator -- it is a mix of QtQuick QML and supporting C++. I think this is a fairly typical approach, but if I'm doing something that is making my life more difficult, please point me in a different direction.
In Marge's qml.qrc file, I have added a element that contains 3 entries (so far) that reference .qml and .ui.qml resources in the patty project:
<qresource prefix="/forms">
<file>../patty/StatusBarForm.ui.qml</file>
<file>../patty/Tempo.qml</file>
<file>../patty/TempoForm.ui.qml</file>
</qresource>
I do see these resources in Qt Creator in the marge project navigator, but I cannot figure out how to now use those resources in my other QML files in marge. I'm expecting to be able to have a StatusBar.qml file, for example, that would contain something like this:
import QtQuick 2.0
import "qrc:/forms/../patty/StatusBarForm.ui.qml"
StatusBarForm {
}
That doesn't work for me and that's what I'm trying to figure out.
There is a chapter named Converting UI Projects to Applications in Qt Design Studio Manual.
Basically, you just copy QML files and related assets from the Qt UI Quick project (Design Studio project) to your qmake based application project (.pro project), and add them to Qt resource file(s) in it.
FYI: Qt Creator supports adding new resource files and adding existing files and existing directories to resources.
Answer to updated part:
You can use file tag's alias attribute in your resource file.
<qresource prefix="/">
<file alias="StatusBarForm.ui.qml">../patty/StatusBarForm.ui.qml</file>
</qresource>
And if you leave qresource tag's prefix attribute to point to root as above you don't need to import forms directory in your QML file. Otherwise, you add import "qrc:/forms", so you import a directory, not an individual file.
import QtQuick 2.0
StatusBarForm {
}
It would make sense to add a separate resource file for external resources, e.g. patty.qrc, instead of collecting everything to the default generated qml.qrc. (Qt Creator: Right click on top of project -> Add New... -> Qt -> Qt Resource File)

Qt Creator: how to create Qt6 project?

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.

Cannot find qml.ui file in visual studio

I made a simple qt widget application using visual studio there were UI form files which I can open and edit UI in qt designer, now I want to shift to qml, I made a new qtquick application but I cannot find any qml.ui files.
What You are talking about is QT Quick UI Form which has the extension ui.qml. This ui.qml file is not "bundled" together with a new Qt Quick Project. You Can take a look for Yourself in the Qt Creator:
Go to: File -> New File or Project
Under the Projects section there is an option that You have probably chosen: Application (Qt Quick) which creates a new application
Under the Files and Classes section there is an option Qt and then You can choose to create the file You were looking for: QtQuick UI File:
As You can see, it says that it creates the form as a ui.qml file, that You can later add to an existing Qt Quick Project.
This is why You can't find the file with the form - You have to create it separately.

Cannot create Qt qml project with Qt commercial charts

Getting error
module "QtCommercial.Chart" is not installed
when trying to import
QtCommercial.Chart 1.3
in qml file
Please help
Assuming you have a commercial license, and have downloaded Charts via the Maintenance Tool... Unlike other Qt modules, Charts does not come pre-built. Only the source seems to be provided (as of Qt 5.2.1). See Digia's QtCharts documentation for instructions on how to build from source, and to include it in your project.

Create simple gui using qtdesigner

I want to create a gui, if it means implementing the code, where do I implement the code? And how to run the qtdesigener?
You can use Qt Designer, or Qt Creator which is a full developement environment (IDE) not just a GUI designer. Visit this site http://qt.nokia.com/products/developer-tools
Each window or widget in Qt generally is defined in 3 files:
some_name.ui - this file is generated by Qt Designer or Qt creator.
some_name.h - this is the C++ header file that contains Class declaration
some_name.cpp - this file contains C++ class implementation
some_name ofourse is the name of your widget/window.
When You add new windows/widgets to your Qt project you have to modify Your *.pro file which contains information on how to build your project.
The following tutorial shows a hello world in qt creator:
http://www.youtube.com/watch?v=QLT7oEt6gLE
I hope this is what you were looking for.

Resources