Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Migrating applications between Qt4 and Qt5
Qt 6.11 is out! See what's new in the release blog

Migrating applications between Qt4 and Qt5

Scheduled Pinned Locked Moved General and Desktop
11 Posts 5 Posters 8.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Search45
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Uhh, just compile it against Qt4. If you have not used any Qt5-specific features then there should very few minor changes to make.

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        [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

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Search45
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #6

              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.html

              If 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.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Serenity
                wrote on last edited by
                #7

                Hi Search45,
                Is it necessary to use cmake?
                I am also wondering, why you have to change highgui to use Qt5 with openCV

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Search45
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    ChrisW67
                    wrote on last edited by
                    #9

                    [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.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      ctsiitmail
                      wrote on last edited by
                      #10

                      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; }

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        ctsiitmail
                        wrote on last edited by
                        #11

                        Please give me solution with solved....Script

                        Warning...1
                        'FileView' has not been declared

                        void 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();

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved