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.
Related
I like to make Qt applications in Visual Studio. But sometimes, there is a need to continue development in Linux space, where Visual Studio is not available. Therefore, there's a need to write down project files manually.
Is it possible to generate .pro files and makefiles from configurated .sln file?
I don't use Microsoft Visual Studio so I never had to deal with .sln files.
But actually, to generate your Qt environment from the command line in linux, you don't need the .sln file.You just have to do as follows:
Create your project directory, let's call it MyQtProject
Copy inside your sources files (.h, .cpp)
Then cd MyQtProject and run qmake -project : It will read your directory and create your .pro file (adding your headers and sources files, ...).
You can edit the generated MyQtProject.pro file to add some specific instructions (for exampleQT += widgets)
Then you just have to run qmake MyQtProject.pro to generate the Makefile.
Finally run make to compile.
Of course, you can create a build directory inside MyQtProject and run qmake ../MyQtProject.pro and make from inside it in order to not pollute your project folder with the moc files and the cmake related files.
I hope it can help you and solve your problem.
I have a folder which has some source in it, that should be ready to compile. The folder has a .pro file in it, which seems to be the compiling file, but how do I use it? I'm trying to create an .exe from it.
The *.pro file normally stands for a project in an IDE.
Since you have the resources file (.rc) it seems the project has been done in Qt Creator.
You can try to download the Qt Creator (and install it) and then by using
File -> Open File or Project
navigate to that .pro file and open it. You can then configure the project and build it.
If the project was not done in Qt, then you will need to be more specific about the problem ...
I am currently trying to port a very large project to QT. Many of the headers in this project use the file extension .hh . I would ideally like to avoid having to rename all of these files, but it appears to be causing some issues for the QT Visual Studio plugin. I am using Visual Studio 2012 and QT 5.5.
I have set up a trivial project to test this problem. If i define a class in a .h file that inherits from QObject and contains the Q_OBJECT macro the Custom Build instructions are automatically added to the files properties and moc'd files are automatically generated. If i rename the file to have a .hh extension no Custom Build instructions are generated and no moc'd files are generated.
I have attempted adding hh to the "Filter" property of the folder/filter containing my header files. This seems to result in the Custom Build instructions being applied to the headers, the correct files being generated by MOC, but not automatically included into the solution. This results the build failing with linker errors.
I would be surprised if this wasn't configurable some how. Has anyone had any success with custom file extensions before?
When I'm loading a certain project using Qt Creator, I get this message repeated twice in the General Messages pane:
Project MESSAGE: You are running qmake on a generated .pro file. This may not work!
Project MESSAGE: You are running qmake on a generated .pro file. This may not work!
Screenshot:
This happens only on one of the projects (this project was created by a colleague, not me, so I don't know what's different about it).
What does this message mean? Is there something that should be fixed in the .pro file?
Project Message: usually indicates that the following text was printed in the qmake file using message(text).
In that case, your best hope is to grep for the message in all .pro files, find out where it comes from and asking your colleague what that message is supposed to mean if you can't figure it out.
Edit: I just found out that the Qt Visual Studio Integration puts this message in autogenerated qmake files. If you or your colleague are using the VS integration, you could remove that message if you do not intend to re-generate the .pro file. The message is basically there to tell you that you might have to adjust some things to make the project build correctly (which it seems to do in your case).
In that case, the code generally looks like this:
# ----------------------------------------------------
# This file is generated by the Qt Visual Studio Add-in.
# ------------------------------------------------------
# This is a reminder that you are using a generated .pro file.
# Remove it when you are finished editing this file.
message("You are running qmake on a generated .pro file. This may not work!")
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.