Building QT with Visual Studio - c++

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.

Related

Can I use Qt visual studio tools for comercial projects?

I understand that I can work on closed source projects using Qt as long as I link dynamically the Qt libraries and don't include them in the release version of my app.
My question is, if I use Qt visual studio tools, would it compile it including the Qt libraries on my release? if so, how could I make use of Qt libraries in visual studio?
Also I guess another question would be, if I use the Qt IDE's like Qt Design studio can I compile my app so that it links the Qt framework dynamically?
This dialog in the installer has the answers to all your questions. So, with these limitations in this wizard, you can use the open source version of Qt in your project.
And yes, you can of course link against Qt dynamically either in qmake or cmake.
All these common and popular IDEs support cmake, like Visual Studio or QtCreator, so you should not worry about using Qt in these IDEs.

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.

Integrating separate Qt and Visual studio 2008 projects together

I have a Qt project(.pro) which essentially uses Qt libraries and OpenGL and i need to integrate this project with an existing VS2008 project(.vcproj) which uses a 3rd party API on another system.
The VS project interfaces with a hardware(along with many other functions) through a serial port and i intend to use its event handler to trigger the actions in Qt( since a serial port cannot be opened by two programs simultaneously? )
I use Qt v4.8.1 with mingw complier. i did come across a VS plugin for Qt. but i'm not sure as to how the above task of integration can be done.
I'll be thankful if you can kindly shed some light on this.
My advice would be to completely integrate the source of the Qt project into the VS project. It's possible to compile Qt code in visual studio. Of course, this requires to configure your VS project to make it "qt-ready". In detail:
Integrate the source code of the qt project into the VS solution. This means, the header files, the cpp files and the ui files you might have.
You still need the Qt libraries on your system in order to compile QT source with visual studio. I recommend to install "qt-win-opensource-4.8.1-vs2008.exe". These are the special Qt 4.8.1 libaries for VS 2008 (pre-compiled). Can be found here: http://download.qt-project.org/archive/qt/4.8/4.8.1/
You have to tell visual studio how to "pre-compile" the Qt source with the installed Qt binaries. This can be down in two ways:
I. You can configure the project properties of your VS project. Unfortunatelly I have never used this way, so I don't know exactly how to do this.
II. You can use CMake to setup your VS project. CMake allows the simple integration of Qt libaries and compilers. Using CMake means to write a CMakeLists.txt, which generates the VS project for you. Here you can find a sample, explaining how to write a CMakeLists.txt with Qt support: http://www.cmake.org/Wiki/CMake/Tutorials/Qt
Also, the Qt plugin for visual studio you mentioned is optional. You do not need it to build a Qt project with visual studio, but it makes some issues easier, e.g. debugging or calling the Qt designer from visual studio.
Hope this helps,
Michael

How do I configure Qt to work with Visual Studio 2010?

I downloaded open-source version of Qt from the site and have compiled it with nmake, but I'm having trouble using it in my projects. It seems that Visual Studio can't find the Qt headers, even though I added the paths to my PATH, INCLUDE, and LIB variables. I tried installing the Qt Visual Studio add-in but it only supports Visual Studio 2008.
Has anyone gotten Qt to work with Visual Studio 2010? Or do I have to wait until Qt 4.7 is officially released for Visual Studio 2010 support?
Either download the pre-built vs2008 package or build it using cmake's vs2008 profile and then open the resulting .sln file in vs2010 and let it do the conversion.
edit - annoying feature so far is that the vs plugin doesn't support vs2010 which makes it essentially impossible to use for desktop app development.
Traditionally VS support was part of the paid licences, with the OS package you only get mingw support. Things are changing, but might have some rough edges for a while.
OTOH, mingw has a HUGE advantage: deployment. You don't have to chase around the vcredist_x86 files and all the associated voodoo. Just be sure to include all the .DLLs you use and that's it.
Also, there's QtCreator. It's not as featureful or omniscient as VS; but it does feel a lot nicer and easier to use. It takes off all the tedious work of nmake, and embeds the UI editors. And it's cross platform!
honestly, for me VS can drop dead this minute and i won't miss it.
Qt V4.8.0 contains prebuilt binaries for Visual Studio 2010 so you don't need to build manually anymore:
http://qt.nokia.com/downloads/windows-cpp-vs2010

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