How to find Version of Qt?
Asked Answered
T

10

79

How do I know which version of Qt I am using? When I open Qt Creator it shows "Welcome to Qt Creator 2.3". In the build setting, however, it shows Qt Version 4.7.1.

Titania answered 14/4, 2014 at 11:18 Comment(0)
A
78
qmake-qt5 --version

or

qmake --version
Armchair answered 6/10, 2016 at 16:21 Comment(1)
I had to use qmake6 --version in Ubuntu mantic.Hunkers
F
51

Starting with Qt 5.3 you can use:

qtdiag

This prints a bunch of useful information. The first line includes the version:

Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.3.1 20160407) on "xcb" 
Fatuous answered 18/10, 2016 at 15:42 Comment(2)
Interesting but OP was for Qt 4 so pyqt 4.xImmaterialize
on my docker container, this says qtdiag: could not find a Qt installation of '' , but build runs through perfectly. QT5, Ubuntu 22.04Overabundance
I
22

All the version info is in PyQt5.Qt:

import inspect
from PyQt5 import Qt

vers = ['%s = %s' % (k,v) for k,v in vars(Qt).items() if k.lower().find('version') >= 0 and not inspect.isbuiltin(v)]
print('\n'.join(sorted(vers)))

prints

PYQT_VERSION = 328193
PYQT_VERSION_STR = 5.2.1
QOpenGLVersionProfile = <class 'PyQt5.QtGui.QOpenGLVersionProfile'>
QT_VERSION = 328192
QT_VERSION_STR = 5.2.0
qVersion = <built-in function qVersion>
qWebKitMajorVersion = <built-in function qWebKitMajorVersion>
qWebKitMinorVersion = <built-in function qWebKitMinorVersion>
qWebKitVersion = <built-in function qWebKitVersion>

The functions can be called too:

>>> vers = ['%s = %s' % (k,v()) for k,v in vars(Qt).items() if k.lower().find('version') >= 0 and inspect.isbuiltin(v)]
>>> print('\n'.join(sorted(vers)))
qVersion = 5.2.0
qWebKitMajorVersion = 538
qWebKitMinorVersion = 1
qWebKitVersion = 538.1
Immaterialize answered 16/4, 2014 at 2:18 Comment(1)
Very useful, thank you for sharing your knowledge. Of the ones you wrote about above I use print("Qt version: " + str(QtCore.qVersion())) and print("PyQt (Python module) version: " + str(Qt.PYQT_VERSION_STR))Costin
W
10

You are using Qt version 4.7.1, because that is the version of the qmake. You can also from shell type qmake -v to get it. The other version, namely 2.3, is the version of Qt Creator, not of Qt

Weekday answered 14/4, 2014 at 11:58 Comment(4)
Thanks @menzZana , can you tell me how to upgrade qt 4.7.1 to qt 5.2.1Titania
You can install new Qt version at qt-project.org/downloads Also you can add the new Qt directly to your Qt Creator, so it uses the new Qt by going to Tools>Options>Build&Run>Qt version and add the new version in Qt CreatorWeekday
My operating System is Fedora 16, is it is possible to install Qt5 ?Titania
Sorry I do not know, since I have never used fedora, but do try to install it. It should workWeekday
S
5

my usual starting point to investigate which software is installed is with

dpkg -l | grep "what I am looking for"

you should get a list of installed packages. Then with

dpkg -L "packagename" # (or whatever your package manager is)

you get a list of installed files for that package

Seventh answered 21/8, 2020 at 11:56 Comment(1)
...Or check with whatever other package manager your Linux distro comes with (pacman, rpm, etc.)Homeless
C
5

If you're using Python:

from PyQt5 import QtCore
print(QtCore.qVersion())

If you're using C++:

#include <QtGlobal>
std::cout << qVersion();
Crossbill answered 20/12, 2021 at 1:42 Comment(0)
C
2

For qt4 :

QT_SELECT=4 qmake -v

for qt5 :

QT_SELECT=5 qmake -v
Cyndi answered 29/5, 2020 at 23:19 Comment(0)
C
2

You can use qmake -query QT_VERSION:

➜  ~ qmake -query QT_VERSION
4.8.7

➜  ~ Qt/5.15.0/gcc_64/bin/qmake -query QT_VERSION
5.15.0

➜  ~ qt-6.0.0/bin/qmake -query QT_VERSION
6.0.0
Crispy answered 27/12, 2020 at 22:44 Comment(0)
T
0

On terminal,qtchooser --l is another way to see the installed instances. The print-out may look like this :

4  
5  
default  
qt4-x86_64-linux-gnu  
qt4  
qt5-x86_64-linux-gnu  
qt5 
Tonguelashing answered 2/10, 2023 at 5:52 Comment(0)
M
-1

If you know the major version that you are running, for example PyQt6, then you can simply type in pip show PyQt6 or PyQt5, etc. If you have no idea and want to write a quick snippet of code to find out:

from PyQt6.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
print("Qt: v", QT_VERSION_STR, "\tPyQt: v", PYQT_VERSION_STR)

Hope that helps!

Mungovan answered 28/4, 2024 at 20:19 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.