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. Qt5 porting tips/findings
Qt 6.11 is out! See what's new in the release blog

Qt5 porting tips/findings

Scheduled Pinned Locked Moved General and Desktop
24 Posts 10 Posters 21.8k 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.
  • T Offline
    T Offline
    tucnak
    wrote on last edited by
    #2

    Thanks for your job. I hope it will help people from devnet.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      frikkasoft
      wrote on last edited by
      #3

      Thank you!.

      When porting one of my projects to Qt5, I wondered why the tcp server had stopeed working. Your tip was exactly what I was looking for, would probably have spent a lot of time trying to figure this out. This is a nasty change for sure

      1 Reply Last reply
      0
      • A Offline
        A Offline
        altera_2011
        wrote on last edited by
        #4

        You're most welcome. That little change cost us a lot of time, glad we were able to avoid others from suffering too much :)

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

          Hi altera_2011, thank you for sharing your findings. I'd like to incorporate them into the official Qt documentation -- would that be ok with you?

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

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DerManu
            wrote on last edited by
            #6

            Great thread!

            I can report some undocumented changes, too:

            • PostScript support (e.g. saving a QPainter-drawn graphic to .ps file) was completely removed, even if the documentation says otherwise. (See "this thread":http://qt-project.org/forums/viewthread/24857/)
            • Whoever switched from QPointer to QWeakPointer for smart QObject tracking in Qt4.6 now must switch back, because this functionality was removed again from QWeakPointer and QPointer was undeprecated. Note that just using QPointer doesn't solve the issue if planning to be compatible with both Qt4 and Qt5, because "QPointer" has different functionality/performance in both versions. (See "this thread":http://qt-project.org/forums/viewthread/27510/)
            • QPixmap::grabWindow was removed. Instead, one could try the QScreen::grabWindow function, although it's not a static one. I haven't found a way to find the QScreen instance the application you want to take a snapshot of is on, so I've settled with QGuiApplication::primaryScreen()->grabWindow for now.
            • QApplication::setGraphicsSystem was removed without replacement. So now it's not possible to set the graphics system to raster or opengl when the native one doesn't properly work or has bad performance. Probably to encourage switching to QML.
            • QTest::qWaitForWindowShown was removed. Functionality is replaced by qWaitForWindowExposed and/or qWaitForWindowActive

            Hope this helps.
            // Edit 09.05.13: added QTest::qWaitForWindowShown

            1 Reply Last reply
            0
            • A Offline
              A Offline
              altera_2011
              wrote on last edited by
              #7

              @JKSH Of course! Go ahead.

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

                I found another previously-undocumented change:

                • QPen now has a default width of 1 instead of 0, so it is no longer cosmetic by default.

                Anyway, most of the changes listed in this thread have are now in the official documentation. Thanks for sharing them here, altera_2011 and DerManu. See https://codereview.qt-project.org/56853

                The patch has been accepted, and the documentation should appear in http://doc-snapshot.qt-project.org/qt5-stable/qtdoc/sourcebreaks.html soon.

                Some notes:

                • The changes to QTcpServer, QPointer and PostScript support were documented before my patch -- you can already read them in the snapshot
                • Did QImage::load() work with sequential devices in Qt 4? If it did, then it's a regression bug, not a porting issue (please report to http://bugreports.qt-project.org/ )
                • The conflict with windows.h is a library conflict, not a porting issue (might still be worth reporting, to see if we can implement an easy workaround in Qt)
                • I could not reproduce the QFrame change -- I created a blank QFrame in Windows 8 with Qt 5.1 beta 1, and it was grey, not white

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

                1 Reply Last reply
                0
                • rootshellR Offline
                  rootshellR Offline
                  rootshell
                  wrote on last edited by
                  #9

                  "QTcpServer::incomingConnection(qintptr handle)"

                  You just made my night, spent an hour looking wondering if I was insane :)

                  Certifications: CISSP, MCITP, MCSE, MCSA, BA, AA, AG, CST, CNST, Linux+, Security+, Server+, Network+, A+, iNet+

                  Languages: C++, C#, VB, Python, Java

                  1 Reply Last reply
                  0
                  • rootshellR Offline
                    rootshellR Offline
                    rootshell
                    wrote on last edited by
                    #10

                    Another good one is QString::toASCI() has been depreciated, use QString::toLatin1()

                    Certifications: CISSP, MCITP, MCSE, MCSA, BA, AA, AG, CST, CNST, Linux+, Security+, Server+, Network+, A+, iNet+

                    Languages: C++, C#, VB, Python, Java

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      altera_2011
                      wrote on last edited by
                      #11

                      Yep. that change is incredibly sneaky since it doesn't throw any error. Glad it saved you some time

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        puffosauro
                        wrote on last edited by
                        #12

                        Hi altera_2011.

                        I'm going to port my Qt 4 application to Qt 5. I have a big Visual Studio (2008) solution with a lot of projects because I have a lot of qt plugins.

                        My doubt is about the Visual Studio project (and not about the application source code).

                        I know that with Qt 5 some modules have changed, so I would like to know what's the best procedure to port the Visual Studio project.
                        I don't know if I can use my old project and change the project settings, or if I must create a new project...

                        Thanks

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          altera_2011
                          wrote on last edited by
                          #13

                          puffosauro, I wish I had good advice for you but we use qmake and QtCreator instead of the VS2010 IDE. So in that respect the change to Qt 5 was a non-event as qmake took care of the changes.

                          How did you create the visual studio projects?

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            puffosauro
                            wrote on last edited by
                            #14

                            I have used the Visual Studio Addin to create the VS projects and also to add Qt classes etc... so I don't have a .pro file.

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              altera_2011
                              wrote on last edited by
                              #15

                              I'm sorry I'm not familiar with the VS addin. Maybe someone else can give some suggestions.

                              1 Reply Last reply
                              0
                              • K Offline
                                K Offline
                                koahnig
                                wrote on last edited by
                                #16

                                [quote author="puffosauro" date="1389276361"]I have used the Visual Studio Addin to create the VS projects and also to add Qt classes etc... so I don't have a .pro file.
                                [/quote]

                                You can export the project to .pro file from vsaddin. This is part of the Qt menu in msvc. I have done my migration from msvc to Qt creator that way.

                                Vote the answer(s) that helped you to solve your issue(s)

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  Asperamanca
                                  wrote on last edited by
                                  #17

                                  [quote author="JKSH" date="1369361247"]I found another previously-undocumented change:

                                  • QPen now has a default width of 1 instead of 0, so it is no longer cosmetic by default.[/quote]

                                  Ouch

                                  1 Reply Last reply
                                  0
                                  • P Offline
                                    P Offline
                                    puffosauro
                                    wrote on last edited by
                                    #18

                                    [quote author="koahnig" date="1389278461"]
                                    You can export the project to .pro file from vsaddin. This is part of the Qt menu in msvc. I have done my migration from msvc to Qt creator that way. [/quote]

                                    Thanks. But I continue to use Visual Studio with the addin.

                                    I have seen that it is easier than I thought, it's almost "automatic", I have only to add the new modules using the addin and I have to change the names of the libraries in the project settings (eg QtCore4.lib -> Qt5Core.lib)

                                    ....

                                    [quote author="JKSH" date="1369361247"]

                                    • QPen now has a default width of 1 instead of 0, so it is no longer cosmetic by default.
                                      [/quote]

                                    mamma mia!!!!!! :(

                                    1 Reply Last reply
                                    0
                                    • P Offline
                                      P Offline
                                      pedromateo
                                      wrote on last edited by
                                      #19

                                      ERROR: 'class QApplication' has no member named 'argc'

                                      FIX for QApplication::argc():

                                      @
                                      s_argc = app->arguments().size();
                                      @

                                      FIX for QApplication::argv():

                                      @
                                      s_argv = new char*[s_argc + 1];
                                      //
                                      for (int i = 0; i < s_argc; i++) {
                                      // current arg
                                      std::string arg =
                                      app->arguments().at(i).toStdString();
                                      // copy arg to char** structure
                                      s_argv[i] = new char[strlen(arg.c_str()) + 1];
                                      memcpy(s_argv[i], arg.c_str(),
                                      strlen(arg.c_str()) + 1); // +1 for '\0'
                                      }
                                      s_argv[s_argc] = ((char)NULL);
                                      @

                                      My two cents :-)

                                      Pedro Mateo
                                      pedromateo@um.es
                                      http://www.pedromateo.es

                                      1 Reply Last reply
                                      0
                                      • P Offline
                                        P Offline
                                        pedromateo
                                        wrote on last edited by
                                        #20

                                        ERROR: 'class QApplication' has no member named 'argc'

                                        FIX for QApplication::argc():

                                        @
                                        s_argc = app->arguments().size();
                                        @

                                        FIX for QApplication::argv():

                                        @
                                        s_argv = new char*[s_argc + 1];
                                        //
                                        for (int i = 0; i < s_argc; i++) {
                                        // current arg
                                        std::string arg =
                                        app->arguments().at(i).toStdString();
                                        // copy arg to char** structure
                                        s_argv[i] = new char[strlen(arg.c_str()) + 1];
                                        memcpy(s_argv[i], arg.c_str(),
                                        strlen(arg.c_str()) + 1); // +1 for '\0'
                                        }
                                        s_argv[s_argc] = ((char)NULL);
                                        @

                                        My two cents :-)

                                        Pedro Mateo
                                        pedromateo@um.es
                                        http://www.pedromateo.es

                                        1 Reply Last reply
                                        0
                                        • P Offline
                                          P Offline
                                          pedromateo
                                          wrote on last edited by
                                          #21

                                          ERROR: 'qWaitForWindowShown' is not a member of 'QTest'

                                          FIX:
                                          @
                                          QWidget* panel;

                                          panel->hide();
                                          panel->show();

                                          #if QT_VERSION >= 0x050000
                                          QTest::qWaitForWindowActive(panel);
                                          #else
                                          QTest::qWaitForWindowShown(panel);
                                          #endif
                                          @

                                          Pedro Mateo
                                          pedromateo@um.es
                                          http://www.pedromateo.es

                                          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