Reputation: 6494
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
Upvotes: 2
Views: 13466
Reputation: 96157
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
Upvotes: 2