Migrating applications between Qt4 and Qt5
-
Hi, I have one application that was developed using QT5 and QtCreator 2.7.0, my problem is that there isn't support for using the OpenCv functions in Qt5 (I tried to compile the opencv code using CMake but when I want to compile with mingw32-make, it generates errors like "QtGui / QApplication No such file or directory" ) and I need the opencv functions for my project.
I want to ask you if there is any way to pass the GUI to Qt4 or do you have any suggestion?
Thanks in advance. -
Uhh, just compile it against Qt4. If you have not used any Qt5-specific features then there should very few minor changes to make.
-
[quote author="Search45" date="1366237044"]there isn't support for using the OpenCv functions in Qt5 (I tried to compile the opencv code using CMake but when I want to compile with mingw32-make, it generates errors like "QtGui / QApplication No such file or directory" )[/quote]Which files produce those errors? If I'm not mistaken, OpenCV itself doesn't depend on Qt, so the core OpenCV library shouldn't contain Qt code. Are you using optional packages?
Anyway, <QtGui/QApplication> were from Qt 4; it is replaced by <QtWidgets/QApplication> in Qt 5.
This page shows that someone got Qt 5.0.1 and OpenCV working together: https://code.google.com/p/qt-opencv-multithreaded/wiki/Documentation
-
There are optional Qt components in the bundle (highgui module: window_QT.*). Nothing in them seems too hard to adapt for Qt5: just remove the module names and perhaps add "widgets" to the QT variable (however that is done in CMake).
bq. Anyway, <QtGui/QApplication> were from Qt 4; it is replaced by <QtWidgets/QApplication> in Qt 5.
You shouldn't include either of them prefixed in this form. Use:
@
#include <QApplication>
@
and ensure that your PRO file contains something like:
@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
@
and your source will build under Qt4 and 5 without changing every include to switch -
Hi ChrisW67, thanks for your answer, but I don't understand what do you mean "remove modules names and add widgets to the Qt variable in Cmake" because I find a lot of option when I expand QT in CMake like QT_QTCORE_LIBRARY, QT_QTGUI_LIBRARY,... and i don't know where exactly I have to put "widgets". Or do you mean to modify the window_QT file of module highgui of opencv?
Thanks for your help. -
I expect you can build OpenCV with Qt options under Qt5 with minor modification to the source files in highgui. How you adjust the OpenCV CMakeLists.txt to make CMake detect and use Qt5 is a question for CMake people but you could read this:
http://qt-project.org/doc/qt-5.0/qtdoc/cmake-manual.htmlIf you would rather use Qt4 to build OpenCV and your application then you do not need the the Qt5-only "widgets" module. The comment about removing the module names from your #include lines still applies though if you expect to migrate to Qt5 easily.
-
Hi Search45,
Is it necessary to use cmake?
I am also wondering, why you have to change highgui to use Qt5 with openCV -
Hi; I'm trying to use the cmake because when I try to compile using the libs for mingw which comes with opencv my application to show an image it runs without problems but the image is not displayed. I have read to correct the problem you have to build opencv from source so I will try to update my version of cmake to 2.8.10 (i was using 2.8.6) and tell you if it works. thanks
-
[quote author="Serenity" date="1366354431"]I am also wondering, why you have to change highgui to use Qt5 with openCV[/quote]
OpenCV highgui contains some (optional) Qt code that is written with includes in the form:
@
#include <QtGui/QApplication>
#include <QtGui/QGraphicsView>
#include <QtGui/QBoxLayout>
@
The use of the module name in the includes means it will not compile with Qt5 as-is because, for example, QApplication does not exist in Qt5's QtGui. There does not seem to be much else that would stop it building with Qt5 after you add the widgets module to the build. -
Please help me with header define script solved qt 5.2
thax.
#define SL_FILESTORAGEDIR
static QString fileStorageDir(void) { lmcSettings settings;
QString path = QDir::toNativeSeparators(QDesktopServices::storageLocation( QDesktopServices::DocumentsLocation) + “/“SL_FILESTORAGEDIR); path = settings.value(IDS_FILESTORAGEPATH, path).toString(); return path; } -
Please give me solution with solved....Script
Warning...1
'FileView' has not been declaredvoid updateProgress(FileView* view, qint64 currentPos);
Warning...2
expected ',' or '...' before 'state'void setButtonState(FileView::TransferState state);
Warning...3
'Ui' does not name a type
Ui::TransferWindow ui;
Warning...4
template argument 1 is invalid
QList<FileView> pendingSendList;
Warning...5
request for member 'clear' in '((lmcTransferWindows*)this)->lmcTransferWindow::pendingSendList, which is of non-class type 'int'
pendingSendList.clear();