Qt Compilation - Using qmake on Windows - c++

I'm having a bit of trouble trying to compile Qt programs under Windows. I'm on a work machine so I'm trying to be wary about what things I'm installing/setting up etc since I was given a procedure to follow originally to get this working (That didn't work), so please keep that mind.
My development environment is normally Visual Studio on Windows 7. To install Qt I unzipped a few files into C:/Qt and setup my environmental variables to reflect it. I've written a short example file in Visual Studio and was able to have it compile; however things got tricky once I started using more than one file in the project.
For example:
Attempt 1 - Only had 1 .cpp file; ran 'qmake -tp vc projectname.pro' then went back into Visual Studio and loaded in the project, Built, and ran the file fine.
Attempt 2 - Had the original .cpp file, added a .h & .cpp to reflect a popup dialog, ran 'qmake -tp vc projectname.pro', loaded in the project, and my two new files were gone.
So two questions here:
1) How do I have multiple files when working in Visual Studio?
2) If I'm making a file from scratch just using notepad, how do I proceed? (ie: I make projectname.cpp, Use the designer to create the .ui file, run 'qmake -project' and 'qmake -tp vc projectname.pro' and the .ui file is not converted into the .h file as it's apparently supposed to do.
Reading "C++ GUI Programming with Qt Second Edition (ISBN-13: 978-0-13-235416-5) if it's of any help.
Thanks,
Thomas

Install the visual studio addin (*) it detects the Q_OBJECT macro and handles all the extra build steps
If you want to use qmake it's described here, it's a nicer simpler format than regular makefiles and the VS addin-can convert between .pro files a visual studio solution.
(*) scroll down to other downloads, select version 1.1 for Qt4 or 1.2 for Qt 5

Related

Required to update Qt .pro and Visual Studio .vcxproj on new file additions

I'm developing using Qt Creator and Visual Studio. However, if I add a new file to the project through Visual Studio the Qt .pro file is out of sync and does not show the new file. Additionally, if I add a new file via Qt Creator the .vcxproj file doesn't get updated and therefore Visual Studio is out of sync.
I am using Visual Studio on Windows and Qt Creator on Linux.
Is there a proper way to manage this type of situation or is this something I just need to keep updated manually if I want the two project files?
There are a few options:
1) Use only Qt Creator, since it runs on both windows and linux it's an good option.
2) Only use the .pro to add files (options/etc), basically only use qmake build system to modify the anything build related and after each change re-create the VS files by using Open Qt project file (.pro) from Qt menu in Visual Studio.
3) Use a completely different build option that can be used on all the platforms you need, for example cmake is a good option and both Visual Studio and Qt Creator have support for it (i didn't used it, so i don't know how easy it's to setup, but i assume it should be relatively easy).

compiling c++ projects with sln file in ubuntu

This may be a stupid question, but I've been trying to compile a larger project that was originally associated with visual studio in Ubuntu. I settled on cmake to do this, but it needs a cmakelist file. As I don't want to set this up manually, since I'll have to port several thousand pages like this, is there a way to have cmake read the sln files visual studio generates?
Any way that would let me compile the projects automatically on Ubuntu would be great.

Minko Engine - Cannot compile

Sorry to be such a noob, but this is my first time compiling anything and i seem to have to everything correct. First i downloaded github client, then i cloned the minko SDK, then i download visual studio, then i added the variable in my system for D:\Minko\minko , and then i loaded the solution file in visual studio clicked f7 i think it was and watched it build perfect without errors (before or after i had to run the .bat file, i dont reme,ber the exact order from tutorial). Problem is i do not see any executables for running the minko studio, and when i try to open a .cpp in code blocks i get an error for the header files as well as trying to open the .cpp file in visual studio i click build for one of the tutorial examples aand nothing happens.. Sorry again and thank you in advance. Will there be a .exe any time soon? Oh, i also installed enscriptem just fine in case it was required.
Minko Studio is not part of the open source Minko SDK.
Minko Studio is actually deprecated. It might be soon replaced with a more efficient and powerful Blender plugin, but we have no release date yet.

How to generate Qt .pri files from Visual studio project at the end of the build?

Can I setup my solution in visual studio to automatically generate the .pri files at the end of the build? I thought about perhaps writing a batch file to call a command to generate the .pri files, is it possible to generate .pri files from the command line?
I am working on a Qt C++ application in visual studio made up of 9 subprojects. I also created a QMake based build of the same application using Qt visual studio add in to generate the .pro and .pri files.
The setup is working well, and the application compiles successfully on Windows (using VS2010) and Mac OS X (Qt creator). The problem is that every time I change the projects in visual studio (for example by adding or removing source files), I have to manually regenerate the .pri file for the project so it gets picked up by qmake.
I'm using the Qt visual studio add in v1.1.11. Visual studio 2010, Qt 4.7.4.
I created a small python script to generate .pri files from visual studio .vcxproj.filter files, I've added it to our post build script that runs at the end of the visual studio build, and it seems to work quite well. If anyone else wants it, you can find it here:
https://github.com/JamesSmaldon/prigen.git
You know, Visual Studio is independent on Qt environment. The only opportunity to do what you want is use of some VS plugins, but I've never actually seen such an option anywhere.
As for me, when I add some file to VS solution, I append it manually to the *.pro file.

Visual Studio 2010 C++ native debug mode resources

I am very desperate now...
I have project in Visual C++ 2010 using Qt and OpenCV. I got to phase I need to load XML file using openCV. But, I have no idea where is the working directory of my project, when run thru VS (F5). I mean, I read all config, copied desired file almost everywhere in my project folders, but it still is not seen by my EXE (OpenCV)...
What Am I doing wrong? Thanks.
right click on your project click on properties/Configuration Properties/debugging you start in whatever working directory is set to.