Which version of QT is compatible with opencv 4.5.4

hi :slight_smile:
Which version of QT is compatible with opencv 4.5.4 ?

for create button i want use this function cv::createButton but i cant! i must build opencv with QT

and how download opencv?
i saw this link : https://www.qt.io/offline-installers
i downloaded this 3 packet :

  1. Qt6 source packages [ 1.0 G ]
  2. 5.15.x source packages [ 962 MB ]
  3. 5.12.x Offline Installers [ Windows Host, 3.7 GB ]

But! None suitable for opencv cmake! I enabled this flag [ WITH_QT ] and for this flag [ Qt5_DIR ], i downloaded and extracted this QT [ 2) 5.15.x source packages ] and set this directory I do:


Nothing happened when I pressed the ‘configuration’ and 'generate ’ buttons on cmake, tell me cmake again : Qt5_DIR-NOTFOUND
again i downloaded [ Qt6 source packages ] and exatract, again…


OpenCV is compatible with any QT5 or QT6 library.

But you need to install Qt, not just get those packages. Download the Qt online installer, chose a Qt library version and install it. It is correctly installed if you see the Qt creator in the Start menu.
To double-check, you can try to build an example project from the Welcome screen.

Now cmake should find Qt.

If you still encounter problems, try to set manually the Qt5_DIR cmake flag to [Qt install folder]/[Qt version]/[compiler]/lib/cmake/Qt5

1 Like

I downloaded offline installer file [ 5.12.x Offline Installers, Windows Host, 3.7 GB ]
With your help, I set the path in cmake [ Qt5_DIR flag ], In cmake I pressed the configure and then generate buttons, no problem occurred and everything was done correctly.
i pressed “open project” button and build visual studio project, but show me 631 error!
Where is my mistake?

All errors are from the opencv_world project!

I disabled the BUILD_opencv_world flag in cmake → then build project in Visual Studio, all errors were from the opencv_highgui project. [ 631 error again ]

I rarely use Windows, but it’s a link error concerning the Qt libraries. Check if all the folders related to Qt (like Qt5Gui_DIR) was correctly configured in cmake.
If it still gives errors, try to add the Qt5 lib files manually in Visual studio Project settings -> Libraries.

yes all QT paths are correct (like Qt5Gui_DIR)
i change compiler? now i use mingw73_64, now i go try this : msvc2017_64

i use msvc2017_64 and build opencv - no error! - for what? :expressionless:

Why !!! After doing all this, I can not find QT dlls in this path :
note : i disabled this flag [ BUILD_opencv_world ]

for example i can find this 2 dll [ Qt5Widgets.dll, Qt5Widgetsd.dll ] in qt installation folder [ C:\Qt\Qt5.12.11\5.12.11\msvc2017_64 ], But I can not find them in the opencv installation folder!

then you have to build the qt libs first for mingw