Qt QML/Quick component missing in Qt Designer - qt

I have created some Quick components, each in its individual .qml file and defined by a root Item object.
I would like to interact with those items through the Qt Designer in Qt Creator, in order to assemble my screens more easily.
However it only shows the .qml files from a folder that I created called qml/. It does not index sub directories such as qml/misc/, etc.
Already tried
Updated the environment variable QML_IMPORT_PATH and QML2_IMPORT_PATH in my .pro
Closed my project between QMake calls and reloaded the Designer
It only works if I place every .qml file inside the qml/ folder

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)

How to create a shared library of just QML files

I am working on project that will hold shared qml components such as a button, status bar, numeric key pad, etc. I want to be able to compile these qml files into one binary (.so/.dll) to provide for use for multiple applications. currently this is my folder structure for the shared application which is setup as a lib
SharedProject (folder structure)
- .pro file
- sharedassets.qrc
- sharedcontrols.qrc
- sharedassests (folder)
-.qml
-.png
- qmldir.txt
- sharedcontrols (folder)
- *.qml
-qmldir.txt
In my test application I am trying to get these controls to show up through a compile library or rcc file but I am unable to I have tried the following
QResoure::registerResoure() in the main.cpp of the test application
QML_IMPORT_PATH += dir of the SharedProject
QML2_IMPORT_PATH += dir of the SharedProject
(The above works but still requires me to have the qml files within some folder. I need them to be binary and then be able to utilize them in qt creator)
any help on how to properly put my qml into a complied library would be helpful. I have read the Qt modules tutorial but still feel lost on how to accomplish this. If anyone has an example that I can reference would be vary helpful.

Can not find header and source files when i create a new project in Qt creater

I am new to Qt. I installed Qt 5 but when i create a new project (Qt widget application) i do not find headers and source files like main.cpp and mainwindow.ui and mainwindow.cpp Although *.pro file is there but nothing else.
mainwindow.cpp does appear on the text editor but there is a message above that
"This file is not the part of any project."
When i checked inside the project directory i can see all the files present but in Qt creator i can not access any of them.
Please help.
The files that Qt Creator generates for you when you create a new project depend on the type of project that you choose to create. F.ex. when you create a new Empty qmake Project, only the .pro file is being created. You can choose a different type of project when creating one, so that Qt Creator will auto generate some more files depending on your needs.
You can add new files to your project by right clicking on the main project folder in Projects menu and choosing either Add New... to create a new file or Add Existing Files... to point Qt Creator to the files that you already have.
This will add a link to the new file in to the .pro file. Lower is the content of the .pro file after adding a couple of new files to the project.
You can also edit the .pro file by hand instead of using the IDE, but Qt Creator (and qmake as well) won't know about the files in your project folder until you add them to the .pro file.

Qt Creator not able to view source code

I have started to develop an app using Qt Creator, and I am dealing with signals and slots. The problem I have is that I have no way to figure out how to view the code generated from my .ui file I am building. I want to edit some signals and slots but I can't do more than the GUI stuff. Is there a way to view all the source code that is generated when I build my .ui file in creator, or do I have to use another part of the Qt suite?
The .ui file is fed to uic to generate .ui.h file. You should be including that file in your code. Place the cursor over the name of the include file within the #include "foo.ui.h" line, and press F2 to see the contents of the file.
There is no other output from a .ui file. "Qt", specifically the Makefile for your project, doesn't generate anything besides a .ui.h file.

Qt Creator doesn't display QML folder

I have a Qt project in Qt Creator. I have a qrc file with the QMLs registered and everything works. However for some reason the "projects" view of Qt Creator doesn't show the QML folder (screenshot attached) like it does for any example project.
I'm just curious. Why does QML folder not show in my project but it shows up for the example projects?
You need to add them to your .pro file (if I'm not wrong it's enough to append them to DISTFILES).
Figures that you have to add the files to the DISTFILES directive.

Resources