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

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).

Related

Building QT with Visual Studio

I know there have been a few questions before regarding this, but not too much up to date.
I am developing a project with Visual Studio 2015 express edition and I wish to add a GUI to my project via QT.
The latest version of QT (5.8.0) has a VS 2015 version, so I assume it is compiled using Visual Studio instead of MinGw.
Sorry if this is a very noob question. I have no experience with QT, but how do I then integrate my QT project into my VS project, do I build the GUI code first in QT?
If I will create a GUI using the .ui file in QT and then generate the source code for this, can I just copy the source code to my VS Project. I assume I have to configure the project file in VS as how will VS know where to find the dlls and header files for QT? Thanks in advance
You need the VS Tools for Qt. They work with >= Visual Studio 2013 Community Edition.
You can get them here and all information about how to use them.
Qt VS Tools integrate the Qt development tools into Microsoft Visual Studio 2013, and later. This enables developers to use the standard Windows development environment without having to worry about Qt-related build steps or tools.
The main features of Qt VS Tools are:
Wizards for creating new Qt projects and classes.
Automated build setup for the Meta-Object Compiler (moc), User Interface Compiler (uic), and Resource Compiler (rcc).
Import and export of Qt project files (.pro) and project include files (.pri).
*Automated conversion of a Qt VS Tools project to a qmake project, or the other way around.
Integrated Qt resource management.
Integrated Qt documentation.
Debugging extensions for Qt data types.

Export Visual Studio project to Qt Project

I would like to export my Visual Studio Project to a Qt project.
How to generate a .pro file from a Visual Studio Project? I installed the Qt Add-In but I don't find such option.
With Visual Studio Qt plugin installed (officially named Qt VS Tools, can be downloaded from here), just:
Open your solution.
Select any Qt-based project from your solution (or any file within that project).
Go to menu Qt VS Tools > Create basic .pro File.... If you are using an old version of the plugin, menu may be named Qt5.
Select the projects you want to export. Project tags (.pro options, only in newest plugin versions) are automatically extract from your current project, you can modify them if needed or do it later when the .pro is created.
Run qmake or open it from Qt Creator.
PS: depending on your VS and Qt versions you may need an older version of the plugin. I'm assuming Qt 5 here.
Hope it helps.

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.

Qt Compilation - Using qmake on Windows

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

Instruction for installing an environment with Qt and Qt integration with Visual Studio 2008

I want to use Qt lib but I don't know how to install Visual Studio 2008+Qt+Qtintegration. I have read some forums, that step by step tell what to download, where to download from, and then what to do. But that was for old versions of mentiond products.
I ask to Qt developers tell me the way to install these items on Windows. Any forum or site will be fine.
Thanks.
To get QT working with dev studio you need to install two things.
First, a copy of the QT Visual Studio Libraries.
And the QT Visual Studio Addin.
http://qt.nokia.com/downloads/windows-cpp-vs2008
http://qt.nokia.com/downloads/visual-studio-add-in
Download the QT sdk, and install it. It usually installs into a folder like
c:\qt\4.6.2
Then, install the visual studio addin. The addin should add (At least) two new things to Visual Sutdio. A new "Qt" project in the Create New Project Wizard, and a Qt menu.
Qt supports building your project against multiple builds of Qt, so the first thing you need to do is go to the Qt menu, and point it to the directory you installed the Qt SDK to. It all went well it should auto populate with c:\qt\4.6.2
Then, use the Wizard to create a new Qt project in Visual Studio.
If you are creating your first Qt project in Visual Studio this way, there is no need to fiddle with .pro files or doing any kind of "stuff" outside Visual Studio to get a project going. The Visual Studio addin sets up the workspace to do all the pre-compiles needed by the Qt build environment.
--
Note: The Qt SDK at this URL
http://qt.nokia.com/downloads/sdk-windows-cpp
comes with the MinGW runtine for GCC, and Qt Creator embedded. This is no good for Visual Studio. This build installs to a folder like
c:\Qt\2010.2