Multiple Qt versions on Linux - c++

I am currenyly using Debian Jessie and I have Qt Creator installed with Qt 5.3.3. It works fine, however there are some issues like QSystemTrayIcon not appearing properly, which I understand doesn't occur on versions earlier than 5.0.0, so I would like to be able to switch which version I am building with. Where can I download the necessary files that I can then point to from the Qt Versions tab in Qt Creator? Currently I can only choose 5.3.3. I would need something like 4.8.6 too.

You can install the Qt 4 development package, libqt4-dev, using your package manager. If you need a different version, you'll need to build it yourself from one of the source packages in the Qt Project's archive. Make sure to set an install prefix outside of your usual /usr, unless you know exactly what you're doing. Usually the prefix /opt is used for this kind of thing.
After it is installed, you can try restarting Qt Creator, and see if it is picked up automatically. If not, you can add it manually by creating a manual Qt version and pointing it to /usr/bin/qmake-qt4 (or something like /opt/qt-4.8.6/bin/qmake if you built Qt yourself and installed in the prefix /opt/qt-4.8.6). You then need to set up a "Kit" as well, and then you can add a "Kit" to your project build configuration (on the projects tab in the main window).

Related

How to configure QT creator in Mint Linux

I need to write Linux software for labs. Put on Virtual Box Mint (wrote that it is best for beginners fit). Installed QT Creator, like all the files needed downloaded. But in the end I still can not create a project.
Qt Creator is just the editor.
You still need to have at least one version of the Qt framework installed - either from an installer, built from source or from a package manager.
The installer bundles a copy (non optional) of Creator, configured to use it.
If you build from source you will have to add the Qt version (профили Qt) and make a kit (комплектьi) from it and a compatible compiler.

Is there a way to run qmake with QT 5.7 and above?

I have a project I made with Qt 5.7 in QtCreator, but now I would like to be able to build the project with qmake in the terminal rather than through QtCreator. However, I can't get qmake to run with Qt 5.7.
Following the instructions in this webpage, I can switch qmake to qt5 but qmake -v still says I'm running QT 5.2.1. How can I switch this to Qt 5.7?
Edit: Adrien's second comment worked. I was unable to get qmake to switch to Qt 5.7, but I can simply directly call the qmake that came installed with Qt 5.7 like this:
/home/<user>/Qt5.7/Qt5.7.0/gcc<something>/bin/qmake
Short answer: yes of course :)
Each Qt build builds its own qmake binary. So if you already built/installed Qt 5.7, it means you are simply pointing to your previous Qt version's qmake. You can access any Qt version qmake executable from your Qt install folder, i.e. for Linux:
/home/<user_name>/Qt/Qt<version>/<compiler>/bin/qmake
Note that the path to Qtfolder, and its name may vary depending on the settings you used for the first installation.
If you want to use a global setting instead, and if qtchooser -list-versions lists the Qt version you want to use, then make sure to set export QT_SELECT=<Qt version> (without spaces) in the same terminal as the one you use qmake from afterward. Environment variables are not kept when you close your terminal, or shared between different terminals.
export QT_SELECT=qt5
qmake

What should I change in Qt creator to compile using MinGW rather than microsoft compiler

Currently my qmake command in QtCreator looks like this:
qmake.exe D:\programing\myproject\myproject.pro -r -spec win32-msvc2010 "CONFIG+=debug"
Now I do not like the win32-msvc2010 because Microsoft compiler sucks horribly doesn't support C++0x.
So what configuration do I change to use MinGW instead of Microsoft compiler when compiling desktop Windows application?
I walked through the settings and googled but no hints...
Easiest thing to do would be to go here:
Link to Qt downloads page
Scroll down and select Qt 5.6.0 for Windows 32-bit (MinGW 4.9.2, 1.0 GB) this will download the installer (its about 1 GB). Run it and choose all the default options. Then you will have Qt 5.6 with mingw and Qt Creator all setup ready to go.
Note: Before you start that its probably best to delete your current version - if you are not attached to it in any way :)
If you want to change your current setup, then it might be longer-winded to find out what you are missing for mingw. For example you need the mingw qmake (and all the other stuff under the mingw_32 folder) file that would be located here (using default install options):
C:\Qt\Qt5.5.1\5.5\mingw492_32\bin\qmake.exe
to create your "Qt Version" part of the kit. And the actual mingw compiler, which is located here (using default install options):
C:\Qt\Qt5.5.1\Tools\mingw492_32\bin\g++.exe
to create your compiler. Once you have both of these then you can put them together to create your new kit.
But to just add a compiler all you need to do is:
Click compilers tab
Click add and select mingw
A new compiler is added, click it
You will see some options below, add your compiler executable path in (like the one above for example).
And you are done - there are some other options, but you probably don't need to use them.
note my paths are for qt 5.5.1 (obviously) so slightly different to 5.6 :)

Unable to build for Windows on Linux, with MinGW

Because I am not a Java enthusiast, I decided to use C++ and Qt for one of my projects. However, I came across the big cross-compiling Qt problem, and I am unable to produce an .exe file for Windows users.
My setup
Linux Ubuntu 12.04, with Wine and Qt. qmake -v gives the following output :
QMake version 2.01a
Using Qt version 4.8.1 in /usr/lib/x86_64-linux-gnu
I also have a MinGW32 compiler, which can be found at /usr/bin/i586-mingw32msvc-g++. My Wine drive_c folder contains the following Qt directories :
$HOME/.wine/drive_c/Qt/Qt5.2.0/5.2.0/Src
$HOME/.wine/drive_c/Qt/Qt5.2.0/5.2.0/mingw48_32
The mingw48_32 directory contains the necessary include/ and lib/ directories, which are used in my mkspec file, /usr/share/qt4/mkspecs/win32-x-g++/qmake.conf :
QMAKE_INCDIR_QT = /home/me/.wine/drive_c/Qt/Qt5.2.0/5.2.0/mingw48_32/include
QMAKE_LIBDIR_QT = /home/me/.wine/drive_c/Qt/Qt5.2.0/5.2.0/mingw48_32/lib
The problem
According to most guides I've found about Qt cross-compiling, my setup should be enough to run a simple :
qmake -spec win32-x-g++
make
wine /path/to/my/application.exe
But... nothing's linked. QApplication and every other symbol I use in my program are "not found". No QApplication, no QPushButton, no connect(), no SIGNAL(), no SLOT()...
My objective here is to successfully configure QtCreator to use this setup (in an independent build configuration), so that it can build a Linux executable (through the first and working configuration), and a Win32 .exe (through the MinGW setup above). However, I cannot modify a single build step in QtCreator :
Cannot add a "MinGW" toolchain : it is not available in the "Add" dropdown list.
Cannot change the -spec parameter value in the project build configurations panel. The field is non-editable.
Despite guides and solutions I found all over the Internet, my only solution so far is to send my source code to a virtual Windows machine, and have it create a new project with it. On this VM, I could probably compile for Windows... But of course, this doesn't actually sound like a real "solution" to me...
Is there any way Qt(Creator) has finally made cross-compiling easier now ? I'm getting a bit tired of "symbol not found" errors...
First,
sudo apt-get install mingw-w64
Then, check if Qt Creator finds the toolchain.
Next, until Ubuntu starts providing a mingw-w64-qt package, download the Qt source and build it. This is bound to get messy, and maybe even the simplest thing to do is to install WINE and use a Windows Qt version.

Deploy Qt+Boost application on a Mac and Windows

How to deploy Qt+Boost Application on Mac OS X or Windows platform.
I use Qt Creator + Qt 4.6 + MacOS 10.6
How to compile my application into release to run it on another computer w/o installed Qt libraries?
I ship Windows apps built with Qt and I use the Dependency Walker tool to first determine which Qt and MinGW DLLs are required. For Qt 4.6 apps you'll need to always ship the mingwm10.dll and libgcc_s_dw2-1.dll files found in your Qt bin folder (default location of this will be C:\Qt\2009.05\qt\bin).
Depending on which Qt modules you use will determine which Qt DLLs are shipped - you'll always need to ship QtCore4.dll. If you use networking then you'll need QtNetwork4.dll and so on - Dependency Walker will show you.
Note that you should only ship Qt files found in C:\Qt\2009.05\qt\bin and NOT those in C:\Qt\2009.05\bin - the latter folder contains MSVC built Qt DLLs used by Qt Creator and other tools and, assuming you're building using MinGW, these will not work with your app.)
I install these files in the application folder, which isn't ideal if you have multiple products that use Qt. If you are using the same version of Qt for all your projects then you could install the Qt files into a special folder that is then added to the user's PATH. YMMV and this is a big topic in itself.
For Qt, refer to the docs on deployment (Windows, Mac). Keep in mind that Qt is quite big - if you decide to link statically consider building a version of Qt that only contains the modules you need.
Most boost libraries are header only and thus need no deployment. For those that are not (thread, ...) refer to the respective documentation on building and deploy them like any other library.