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. From Qt4 to Qt5, include files not found
Forum Updated to NodeBB v4.3 + New Features

From Qt4 to Qt5, include files not found

Scheduled Pinned Locked Moved General and Desktop
17 Posts 9 Posters 100.6k 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.
  • L Offline
    L Offline
    liuyanghejerry
    wrote on last edited by
    #8

    [quote author="fs_tigre" date="1356702364"]What do you mean with regenerate the mainwindow.h? Delete it and re-create it?

    Thanks[/quote]

    Yes, because there're some include commands in it.

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #9

      My solution was to regenerate a project file (.pro). Through away the old one, including the makefiles. Then generate a new one in QtCreator 2.6.1. Add all the files you need and it works fine. As mentioned above the new project file includes the Qt += Widgets, but there is also some sort of prefix to it.
      It solved my problems, but with QtCreator 2.6.1 I also needed to install the gdb debugger again because it crashed big time.
      Might be better next time if they release a new big release after the holidays ;-)
      greetz

      Greetz, Jeroen

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fs_tigre
        wrote on last edited by
        #10

        I re-generated the .pro file and it did fix some of the errors but I still have some.

        QtGui/QApplication: No such file or directory

        variable 'QApplication a' has initializer but incomplete type

        Is there a list of classes that have changed/relocated?

        This should be easer than this.

        Thanks

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

          Hi fs_tigre,

          This page and its links describe the changes in Qt 5: http://qt-project.org/doc/qt-5.0/qtdoc/portingguide.html ; new features are in http://qt-project.org/doc/qt-5.0/qtdoc/whatsnew.html

          There's no dedicated list of relocations, but AFAIK, they are:

          • QWidget (and all it subclasses) and QApplication moved from <QtGui> to <QtWidgets>
          • QSound moved from <QtGui> to <QtMultimedia>
          • The Qt Mobility framework was split up, and its classes were distributed across different modules in Qt 5

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

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fs_tigre
            wrote on last edited by
            #12

            @JKSH

            Thanks a lot for the links, I made the changes recommended and still endup with a few problems, in fact for some reason when I try to open the from file (mainwindow.ui) Qt5 crashes.

            I'm currently downloading Qt4 from Nokia, I will use Qt4 for existing projects.

            Thank you all very much.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              doru001
              wrote on last edited by
              #13

              Here is my novice proposition:
              @$ cat qt4.sh
              #!/bin/bash

              set -e

              for a in *.{cpp,h}; do
              if [ -f $a ]; then
              sed 's/^#include <QtGui>/#include <QtWidgets>/' $a > /tmp/$a~;
              sed 's/^#include </#include <QtWidgets//' /tmp/$a~ > $a; rm /tmp/$a~; fi; done

              qmake -project

              cat >> *.pro <<-stop

              CONFIG=qt

              QT += widgets

              stop

              qmake *.pro

              make@
              you put this in .. and run it from the project's directory:
              @. ../qt4.sh@

              1 Reply Last reply
              0
              • F Offline
                F Offline
                fs_tigre
                wrote on last edited by
                #14

                Update:

                For me this problem was MAGICALLY solved after...

                -deleting the .pro.user file
                -opening the project with with Qt4
                -finally opening it with Qt5

                and everything was magically solved, no manual modifications. Don't ask me why, but I did this to two of my old projects and they are now working in Qt5, without me moving a finger.

                Side Notes:
                What I noticed is that if you delete the old Qt4 .pro file and then try to open it with Qt5 it will not work it looks like as long as you have the old Qt4 .pro file Qt5 will take care of the header files for you.

                Thanks

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mickey
                  wrote on last edited by
                  #15

                  I have also faced this problem. It was solved by adding this line in .pro file:

                  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                  Try it, It will work hopefully....

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    fs_tigre
                    wrote on last edited by
                    #16

                    Here is my permanent fix.

                    1- Change <QtGui/WidgetName> to <QtWidgets/WidgetName>

                    2- Fix any other includes individually, for instance if you compile and get an error that says unknown type name 'QLabel', include <QLabel>, than compile again to see what other includes are missing, make the proper includes until you don't see any other error.

                    3- Open the .pro file and add QT += widgets at the end of the file.

                    4- Done

                    http://qt-project.org/doc/qt-5.0/qtdoc/portingcppapp.html

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

                      Please help me with header define script solved qt 5.2

                      thax & 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

                      • Login

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