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?
Related
I have a custom build rule on a data file which generates a header file. The custom build rule works fine (runs when the data is changed and does not run when it is not, as I would expect it to).
However, this generated header file is included by a .cpp file which is compiled using the default C++ compiler. When the header is generated and there are no changes in the .cpp itself, the build system will not compile it. I have to build twice, once to generate the header file and then once more for the build system to notice and rebuild the .cpp as well (the generated header has the current date/time so there are no problems there, it just seems that Visual Studio makes all the checks before starting the build).
Not a major issue but it gets annoying after a while. It is also error-prone. Is there a way to either expedite the custom build rule so that it would run before Visual Studio checks the dependences of the .cpp files or maybe to run the build twice? There may be several files using this custom build rule so using a pre-build step to build them all would get messy.
I'm using VS 2008 if that makes any difference. The custom build rule has the "Outputs" field correctly filled in so it has the information about the files the custom build generates.
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'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.
I am converting a C++ project created using Visual Studio 2005 to CMake and have stumbled upon a bit of a problem with resource files that are included in the project.
The project includes a .rc file, a bunch of .ico files and a .rc2 file.
The regular .rc file works fine in the generated project and uses the resource compiler. The .ico and .rc2 files however are causing problems when they are just being included, because in the generated project Visual Studio attempts to compile them using the C/C++ compiler.
I assume that these files are included by the .rc file, so it would probably work to just not include them in the CMakeLists.txt file, but since it is obviously possible to list them in the project (they are visible in the original project) I would like to do so, so that the user of the generated project can see that these files are being used.
What is the correct way to handle these extra VS resource files in CMake?
Try to set_source_files_properties(your.ico your.rc2 PROPERTIES LANGUAGE RC).
By default it shouldn't do anything with those files. The source file property LANGUAGE should be empty and thus the action for the file should be checked by the file type. Which shouldn't be anything since it's not something it should compile.
Check your CMakeLists.txt that is doesn't contain a set_source_files_properties command that would mess with that property.
If you want to do something with the files, here are two ways to do things:
With add_custom_target you can add them and run custom commands for them when you build the project. Granted that the files have changed.
With configure_file you can easily copy them to a build directory if needed. With the COPYONLY flag.
I am using Visual Studio 2010 to build an application in C++. I have a custom build event which creates additional headers and source files in a separate directory. How can I tell Visual Studio to include those generated files in its build queue. I don't necessarily need to add them to the project but I need to compile them like they are part of the project.
If the names of the files don't change, create a folder(filter) called generated and add those files to this folder(filter). If they don't exist VS won't complain when compiling, if they exist they will be included in the build.
I use this scheme when i have to use generated files.
I don't think it's possible (unless there's an add-on for that or something). But what you could do is to generate all those files and then add them to the project. After that in the custom build event specify them as outputs. That way VS will not try to build them before they are generated and will not complain that they are missing.