compile Qt project without installing qt - qt

I have created a Qt 5 project in Qt Creator.
I want to open and compile this project with Visual Studio 2012 on a computer that doesn't have anything about Qt installed. How can I make the qt libraries follow with my project ?

There is also a Visual Studio plugin enabling Qt projects to be build inside Visual Studio IDE as for example this one :
Visual Studio Add-in 1.2.2 for Qt5
(supports versions 2008, 2010 and 2012, does not work with the Express edition)
Qt Project other downloads
With this Add-in and a Qt SDK version for Visual Studio you don't need to install or build with the Qt Creator IDE.
But as drescherjm said the installation of a minimal Qt SDK is further a necessary dependency.

You can use cmake to resolve dependencies to the qt dll files. For example put dynamic libraries in a include-qt5 folder and include the directory in your CMakeLists as follows,
include_directories ("/include-qt5")
To run your program, you need to copy appropriate dll files next to to your executable (you can use windeployqt to do so).
Note! To use qt classes in your code use relative path to the corresponding header files such as #include <QtWidgets/QMainWindow> and so on. You may need to add the following directives in your code to specify the library that you want the linker to search for,
#if defined(NDEBUG)
#pragma comment(lib, "Qt5Widgets.lib")
#else
#pragma comment(lib, "Qt5Widgetsd.lib")
#endif

Related

Installing a compiler for Qt4.8.7 on Windows10

I am trying to install Qt4.8.7 for Windows 10 and I am having some issues with installing the corresponding compiler.
I got the Qt4.8.7 installer from this link: https://download.qt.io/archive/qt/4.8/4.8.7/ and I have tried working with the MSVC2010 and the mingw versions. For the MSVC2010 version, I followed this guide https://wiki.qt.io/How_to_setup_MSVC2010 (with a lot of dead links) and installed the compiler alongside the MSVC service pack 1 and Windows SDK 7.1. I have not been able to find an installer for Visual Studio 2010 or the VS service pack 1. Qt studio recognises the version of qt I have installed alongside the corresponding MSVC2010 x86 compiler but when I compile I get this error for a missing header: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\intrin.h:26: error: C1083: Cannot open include file: 'ammintrin.h': No such file or directory".
For the mingw version, I have not been able to find the correct version "mingw482" and other versions I have tried do not seem to be compatible. I have tried mingw installer programs as well as using the QT online installer to try and find the correct version but I haven't had much luck when compiling.
Has anyone got qt4.8.7 running on windows recently? If so, could you please point me in the right direction for installing the correct compiler?
Many thanks.
Here a short description for getting it to work with Visual Studio 2008 and the newest Qt Creator 4.13.
You will need:
Visual Studio 2008 Express for the build tools, there are no standalone build tools as far as I'm aware
Qt 4.8.7 precompiled for VS2008 from this link to Qt archives at the time of writing this the version you need is called "qt-opensource-windows-x86-vs2008-4.8.7.exe"
Any Windows debugger cdb.exe
Steps (all absolute paths are standard installation paths):
Install VS2008
Install Qt 4.8.7
Open your Qt Creator go to Tools->Options...->Kits->Tab Compilers and search for "Microsoft Visual C++ Compiler 9.0", it probably won't be there so you will need to add it by hand by looking for the vcvarsall.bat of this compiler. You will find it in C:/Program Files(x86)/Microsoft Visual Studio 9.0/VC/vcvarsall.bat. Repeat for C, C++, x86 and x64. Press save
Open the Qt-Versions tab and look for Qt 4.8.7 Version. It will probably not be there again so add it by hand by selecting the qmake.exe from C:/Qt/4.8.7/bin/qmake.exe. Press save
Open the Kits tab and add a new kit. Select your Qt 4.8.7 version and the MS compilers for C and C++, your favorite debugger and input the Qt-makespec win32-msvc2008. Press save again
Now you should be able to compile your project from Qt Creator and Qt-colored-commandline. For integration of MSVC 9.0 into Visual Studio 2015 and newer you will also need to install Visual Studio 2012 Express. In that order:
VS2008
VS2012 (Here MS programmed in some magic so newer VS can see older build tools)
VS201x
It could work in any other order but don't rely on it. Also it could just flat out not work and you will waste a week of your life to fix it; but then it will work.
Haven't tested it but I could imagine the same workflow will work for VS2010.

How to use Visual studio code with Qt/Qmake? (macOS)

How to use Qt with Visual Studio Code? I have Qt 5.15.1 installed which builds my code for macOS, Android and iOS.
Is it possible to have Visual Studio Code build my Qt application for macOS, Android and iOS like QtCreator does?
Environment:
My developer environment is macOS Catalina.
If you're using cmake, which you should, then all you need to do is configure your cmake project to point to your Qt folder, which basically means setting the project's Qt5_dir env variable to point to your Qt installation.
Here's what you need to do to get Visual Studio Code to work with Qt using Microsoft's CMake Tools extension:
Verify that you really have Qt installed,
Install Microsoft's CMake Tools extension,
Open CMake Tools extension's "Edit CMake Cache (UI)"
click on "CMake extension" on vscode's activity bar to open "CMake: project outline",
click on the "View and more actions" button (i.e., elipsis on upper right corner of the project outline.
Edit CMake's cache to point Qt5_dir to ${QTINSTALLDIR}/5.15.1/gcc_64/lib/cmake/Qt5
Rebuild project.
You can achieve the same goal by using cmake-gui to configure your cmake project.
If instead you really want to stick with qmake then it's enough to setup a build task that runs qmake.

How to fix QT VS Add-in for Qt 5.6 beta and VS2015?

I did not compile Qt myself, rather I used installer from official Qt website (5.6 beta is available since few days ago). Installation was successful, Qt folder conatins bin folder with qmake and everything. Building apps in Qt Creator works.
However, when I try to launch Qt using VS addin 1.2.5.9 I get error
No default Qt version found. Pleae check your Qt Visual Studio Add-in
settings.
I have edited QT5 -> Qt Options to contain the correct Qt path to 5.6 beta, error still persists.
I have also added QTDIR into Path in Windows 10.
I am using Community Edition of Visual Studio 2015
How to fix this? Create new Qt project under VS fails as well.
The Qt Visual Studio add-in is no longer supported in Visual Studio 2015.
Microsoft decided to deprecate AddIn support in Visual Studio 2013 and with Visual Studio 2015 all support for it has been removed. This is covered in https://bugreports.qt.io/browse/QTVSADDINBUG-404. However, there's an extension called Qt5Package you can install instead.
I found when I tried to add Qt 5.6.0 Beta in the extension I got the error "This Qt version uses an unsupported makefile generator (used: MSVC.NETMSBUILD, supported: MSVC.NET, MSBUILD)". The workaround is in C:\Qt\Qt5.6.0\5.6\msvc2015\mkspecs\common\msvc-desktop.conf Qt 5.6.0 splits all the version-specific changes into a separate file msvc-base.conf. If you copy the contents of this file and replace the line "include(msvc- base.conf)" in mscv-desktop.conf then Qt5Package recognises the Qt 5.6.0 Beta with no problems.
Note this still needs to be fixed in Qt5Package.

How to install plugins into Qt Designer?

I have scoured the internet for information regarding the installation process for plugins into Qt Designer and I have found no helpful/relevant information.
The plugin I want to install is the echo plugin.
I have also looked through the Qt Designer program files and found the echoplugin folder but have no idea how to install it. Here is the file location:
C:\Qt\Examples\Qt-5.5\widgets\tools\echoplugin
This holds the following file types; Qt Project Files, C++ Header, C++ Source and JSON
System Information
Windows 10
PyQt4
Qt Designer 5.5.0
Official documentation describes it very well.
To install plugin for Qt Designer or Qt Creator you need to place the plugin to plugins\designer directory.
For Qt Creator it is located in it's bin directory.
Qt Designer is a part of Qt installation so directory will be QTDIR\plugins\designer where QTDIR is Qt installation path (for me it is "E:\DEV\Qt\5.5\msvc2015_desktop_shared" and full plugins path is "E:\DEV\Qt\5.5\msvc2015_desktop_shared\plugins\designer").
One important thing - Qt Designer / Qt Creator and the plugin must be compiled using the same compiler version. You can not install plugin compiled with MSVC 2015 to Qt Designer compiled with MSVC 2013!
Edit:
I am using C++ version of Qt.
It looks like echo plugin is not a plugin for Qt Designer / Qt Creator.

QT with Visual Studio 2013 Express

I'm trying to get QT to work with Visual Studio Express 2013.
As first I downloaded sources, and was trying to compile it using Developer Command Prompt for VS2013. Gave up, after adding to QT source files new things, to keep compiler move on.
After that I just installed QT binaries. The QT: "qt-windows-opensource-5.1.1-msvc2012-x86_64-offline.exe"
It has it's own editor, but I would like to use QT inside Visual Studio Express 2013. Can I just link libraries, from Visual Studio Express 2013 project?
I linked C:\Qt\2010.05\qt\include to the Include, C:\Qt\2010.05\qt\lib to the libraries and C:\Qt\2010.05\qt\bin.
But there are a lot os subdirectories, that Visual doesn't include.
Should I wait for QT Sources compatible with Visual Studio Express 2013?
Or can I use it now, like that?
Regards
To do this from cmd.exe you have to edit your PATH by adding QtDir/bin there, then cd to your project directory and write the line written before.
Everything should looks like this:
Run cmd.exe
cd your_project_dir/
qmake -spec win23-msvc2010 -tp vc
After this manipulations you will have .vcproject file in your project directory

Resources