I have a project on visual studio 2010 which uses qt, qrc files and qml. I've put my qml files inside qrc file, so when I rebuild the project my qrc files updates and I can reach my qml files.
The problem is when I update my qml files, visual studio (or qt visual studio plugin) can't detect the change and doesn't update the qrc files. Only thing I can do is either rebuild the project, or make some dummy changes to qrc file (add remove some white-space characters) so that qt plugin thinks that there may be some change in qrc file and it updates the qrc file.
This is time consuming, as I make several changes to my qml files it takes too much time to do this manually every time. Is there a practical way to do this?
Right-Click the file and select compile should do the trick.
Related
I want to add sound to my program so I need to add header file “QSound”.
To add the header file, I need to modify the .pro file.
The problem is, I use visual studio to develop projects, so I can't find the .pro file.
I am so confused.
Thanks for your help!
If you're using Qt VS Tools, use Create Basic .pro File from extensions menu. Note that .pro and .vcxproj files might not be in sync so if possible use Qt Creator to configure your project in the .pro file and then open the project in visual studio via Open Qt Project File
Note that if you are using MS Visual Studio and Qt, and you need to add a specific qt module to your project, you do not need to have a .pro file just for that. That would be the way to go when not using VS.
Instead, in Visual Studio select your project, select menu "Project / Properties", there you should have an entry "Qt Project Settings", and there a section "General", there a setting "Qt Modules" which probably already contains "core" and some entries.
Add your module to this line. Remember to do that for all your configurations and platforms.
I have a Qt project with QML files. Whenever I change these files, I have to manually right click the .qrc (resources) file and recompile it.
How do I tell visual studio to always compile a certain file, not only when it thinks it has changed?
(Here are similar questions others have asked for eclipse and flashdevelop)
I encountered the same problem while building qt apps using Qt Creator.(Especially while using QML files as resources.) I solved the problem using a little hack.
Created a batch file say touch.bat in my source directory.
This batch file contains a single line copy qml.qrc /B+ ,,/Y where qml.qrc is the resource file name.
Opened my project in QtCreator and went to Project->Build Steps->Add Build Step->Custom process step and entered touch.bat
Whenever the project build starts, the qml.qrc is touched. The build system thinks that qml.qrc is modified and builds it.
You can modify this hack for Visual Studio also.(I have not tried). Try adding touch.bat as a build step in Visual studio. The idea is to fool the build system to think that your .qrc is modified.
I guess this is a known bug which remains unresolved. Check this bug report.
Thanks.
I'm using Qt4.8 with Visual Studio 2012 with Qt VS add-in 1.1.8. And I have a problem with moc_ files generation. If I add new class (with .h and .cpp files) to my project, where Q_OBJECT is supplied, then moc_ file is not being generated correctly and I get linking errors.
In .h file's custom build tool's command line, moc.exe's commands should be filled automatically. It seems everything is OK in Production configuration, but in Debug and Release configurations custom build tools command lines are empty and every time I have to write them, build and add moc_ file to my project manually, which is quite inconvenient.
So what can be problem for automatic generation? Which solution can be?
Thank you in advance!
I use Visual studio 2012, and add plugin for QT. How to add new form to main window? When i try to add new item, compiler don't generates code, when i click to .h file it says "the document cannot be opened. it has been renamed deleted or moved".
Thanks.
If you have the Visual Studio plugin installed and you add a new Qt form to the project, two new files are added to your project, a xxx.ui file under the Form Files folder and a ui_xxx.h under the Generated Files folder.
You will be allowed to edit the xxx.ui file by double-clicking on it and Qt Designer will open up.
The ui_xxx.h file will not initially be editable (not that you'd want to edit it anyway) because only a reference to it gets added in the project file, no physical file is created on the disk. The header file is only created when you execute your next build.
EDIT:
If you don't want to do a full build, you could also just right-click on your new xxx.ui file in the Solution Explorer and select Compile from the context menu. That will run uic to generate your header code.
I've created a Qt Application project in Visual Studio 2010. It contains the following files
Form Files
mainwindow.ui
Header Files
mainwindow.h
Source Files
mainwindow.cpp
It also uses a generated codefile called ui_mainwindow.h. From what I've been able to discern, this file should be regenerated in response to changes made to the .ui file. However if I open the ui file in Designer and make a change, no change appears in the application.
I have to go to Form -> View Code -> Save As in Qt Designer and save the ui_mainwindow.h file manually.
.ui file should have custom build tool defined to use uic on it and produce appropriate ui_*.h file.
Custom build tool command line may look like this:
uic.exe "$(InputPath)" -o "ui_$(InputName).h"
Also, in order to properly detect dependencies and to Clean command remove generated file, add ui_$(InputName).h to Custom Build Tool Outputs.
Don't forget to make the changes for all Configurations and Platforms.
Although, the right way to do this would be to create appropriate .pro file and then generate Visual Studio project with qmake -tp vc project.pro. All compiler and linker settings should be adjusted in .pro file, not in Visual Studio project that should be regenerated after each change of .pro file.
i mean no offense but have you saved the .ui file before running the project?
when i need to edit the ui files, i change them with the designer and when i want to run it, it will recompile/moc/whatever the changed ui file and their .h/.cpp file as well.