Cannot find qml.ui file in visual studio - qt

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.

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 add GUI to existing Qt project and how to disable qt shadow build

I am new to QT. And I want to use qt to add GUI to an existing project. I moved the original project to a Qt console application. Then I need to add GUI to it. Where should I start from? I took a look at some qt tutorial tutorials which start from creating new widget project. But there are not many about adding gui to an existing project.
I tried to add "QT += widgets gui" and "FORMS = myproject.ui" in the pro file. But I got error: No rule to make target 'myproject.ui', needed by 'ui_myproject.h'.
Also, can someone tell me how to disable shadow build in Qt creator 3.4.2 (based on Qt 5.5.0)? Thanks.
First of all, to disable Shadow build open "Projects" page from the left menu in QtCreator (right after "Debug") - there you can disable Shadow build option both for debug and release builds.
As for adding GUI I recommend you to create an empty Qt project (if you are using Qt 5.0 or greater you should add QT += widgets to your .pro file). There you can create a GUI you need - using forms or manualy as you wish. When your interface part will be complete you can add a non-gui functional part from existing source code. But that is a rather general recommendation as you see

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.

Qt Creator - how to see the code of the designer?

I'm using Qt Creator.
I'm using the signals and slots editor, and I want to see the code it generates.
How can I see the code?
Thanks!
Let's say you have in Qt Creator a form file called widget.ui.
Once you've compiled your project, you'll find in your project folder a filed called ui_widget.h.
If you open it, you'll see the code generated by the uic tool.
when you use qt creater, this one is going to create a file with the name of your project, in my case it is called "build-prueba-Desktop_Qt_5_7_0_GCC_64bit-Debug", then in that file you have to look for a file with the "ui_" prefix, into that, you have the code you need

HowTo set Icon to Qt Application, created with Qt Visual Studio Add-in?

Here is what I have:
Visual Studio 2008 (on 32-bit Windows XP)
Qt libraries 4.6.2 for Windows (VS 2008, 194 MB)
Visual Studio Add-in (44 MB)
After I installed all the software, I created simple Qt Application project, with Visual Studio: menu File | New | Project... and Qt4 Projects | Qt Application.
Build it, and here is the question: how to set application icon to my compiled exe file? I need to see specified ICO in explorer!
Old method with MyProject.pro not interested!!!
Create a .ico file with both 16x16 and 32x32-pixel versions of the icon (you can do this in Visual Studio).
Create a .rc file containing the following text:
IDI_ICON1 ICON DISCARDABLE "myIcon.ico"
Add the following to your .pro file
RC_FILE = myFile.rc
Run qmake.
Thanks.
This is what worked for me [VS2010, Qt Add-in 1.1.8], for an existing project:
As in the docs at http://doc.qt.io/qt-4.8/appicon.html :
Add icon file (myappico.ico) to source dir
Create myapp.rc file with the line
IDI_ICON1 ICON DISCARDABLE "myappico.ico"
[Of course, the file names are free to choose, as long as they are consistent]
Right-click project, choose Add | Existing item... and pick the RC file
Rebuild
Totally, I have found the correct solution, here it is:
Preamble: You need Visual Studio Add-in already installed!
Open Visual Studio (or Visual C++)
Create new project from menu: File | New | Project... and select project type as Qt4 Projects and for example Qt Application from templates.
When the first dialog window will be shown, just click Next > button twice.
And finally in Generated Class tap the Add default application icon (Windows only) checkbox.
alt text http://www.freeimagehosting.net/uploads/7f87801fb9.png
To finish process, just press Finish.
Project will create a default icon, with name {your_project_name}.ico. Replace it and have fun!
From official document, it says:
If you do not use qmake, the necessary steps are: first, run the rc program on the .rc file, then link your application with the resulting .res file.
I tryed several times, it should be done like below:
1. Add an ico resource file to your project;
2. rename the file "yourappico.ico";
3. rebuild your project to generate yourapp.res file;
4. link your application with the resulting .res file.
( Projects->Properties->Linker->Input->Assembly link resource )
You could also load it in manually. Following approach works for me:
#include <QtGui/QIcon>
QIcon icon("Resources/appicon.ico");
QMainWindow *window = new QMainWindow();
window->setWindowIcon(icon);
window->show();
Put your .ico file inside the Resources-Folder of your VS-Project.
(oops, did not fully read the question, but I just leave the answer it anyway... ^^)
Right click you project on Solution Explorer and using the "Add" option include your icon in the project. It will include your icon and setup a rc file for you.

Resources