Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    [Solved] "QTableWidgetItem: No such file or directory" in Qt 5

    Installation and Deployment
    2
    8
    6565
    Loading More Posts
    • 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.
    • I
      isaacEnrique last edited by

      Greetings.

      I just installed Qt 5, specifically Qt 5.0.1 for 32-bit Windows (MinGW 4.7, 823 MB). Download it from http://qt-project.org/downloads.

      The entire installation process went well and achieved successfully execute several ejmplos demonstration.

      However, when I try to run a program spreadsheet that I made some time ago (this is really an example program that appears in the book "C + + GUI Programming with Qt 4" which I completed), I get the following error message :

      "QTableWidgetItem: No such file or directory"

      Even for other sample programs that I did get this error message:

      "QtGui / Application: No such file or directory"

      All these programs ran perfectly when I wrote and run using QtSDK 1.2.1 (which was the version of Qt that was using until now to install Qt 5).

      So what is the problem or that you need:

      • I did the installation wrong?

      • I need to do something else after installation? (I just follow the installation wizard)

      • How do I fix this problem? ... Should I change any environment variable?

      Right.
      As always thanks in advance for any responses and/or comments

      Isaac Pérez
      Programming is understanding.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Is QT += widgets missing in your pro file ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • I
          isaacEnrique last edited by

          Yeah, that line was missing (with the version of Qt that I was working previously did not need to add that line ... I guess it's something new in Qt 5).

          I added the line and the error no longer appears, but now are many others who do not really understand.

          In the header file of one of my classes I have several "forward declarations":

          QCheckBox class;
          QLabel class;
          QLineEdit class;
          QPushButton class;

          Apparently these are generating errors.

          Specifically, I get:

          invalid use of incomplete type 'class QLabel'
          C: \ Users \ PROJECT \ Documents \ files - isaac \ examples Qt \ findDialog \ finddialog.cpp: 10: error: invalid use of incomplete type 'class QLabel'

          forward declaration of 'class QLabel
          C: \ Users \ PROJECT \ Documents \ files - isaac \ examples Qt \ findDialog \ finddialog.h: 14: error: forward declaration of 'class QLabel'

          Similarly for the other classes shown above.

          In the corresponding .cpp file, I only included the head <QtGui>.

          Isaac Pérez
          Programming is understanding.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            QtGui is Qt 4 and you should avoid using it anyway. That pulls a whole lot of unused includes (which must be parsed and thus slow down the compilation time)

            Simply add the includes for all your forward declared class and you'll be good

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • I
              isaacEnrique last edited by

              Thank you very much, I solved the problem.

              However, I noticed that I had to include a number of header files in first I thought they were not needed.

              For example (just to name one), in my class 'MainWindow' (which is a subclass of QMainWindow) I had to include:

              <QMenuBar> (I guess because I call the function 'menuBar ()').
              <QStatusBar> (I guess because I call the function 'statusBar ()').

              I thought:
              To include "MainWindow.h" (which includes <QMainWindow>) should be enough, or am I wrong?.

              I supposed that this is how it works Qt5?, Or else:
              Is there a problem with my installation Qt5 or my program?

              Isaac Pérez
              Programming is understanding.

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                You're welcome !

                You are wrong, QMainWindow does also make use of forward declarations. You only need to include the headers for the stuff you use.

                It's not the way Qt 5 works and your installation is fine. It's the fact that you were including QtGui that pulls Everything from the QtGui module. It's useful when writing a quick test application but good code practice tells that you only include what you use (also for compilation performance reason)

                Don't forget to update the thread's title to solved so other forum users may know that a solution has been found :)

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 0
                • I
                  isaacEnrique last edited by

                  Indeed, this spreadsheet application was one of the first applications that I wrote when I was just starting with Qt (now I have a little more knowledge, but I'm still a newbie in Qt).

                  It was only a sample application that was all by using to test my installation of Qt5.

                  Well, to sum (actually, to see if I understood well what you trying to say):

                  • You need to include the headers <QStatusBar>, <QMenuBar> and other, even if already been included <QMainWindow> (in fact I had to include those in my class 'MainWindow', which inherits from QMainWindow)

                  • According to the above... my installation of Qt5 is okay.

                  Please excuse the inconvenience.

                  Isaac Pérez
                  Programming is understanding.

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    If you take a look at the QMainWindow header, you'll see that it includes only QWidget and QTabWidget, the rest is only forward declaration, which is why you have to #include <QStatusBar> when you want to call statusBar() and use the returned QStatusBar.

                    • So: no, you have to include them when they are not already included in an other header AND that you need to instantiate an object, use an object, a static function or an enum from that class. Thus if you only have pointers i.e QMenuBar *menuBar(), use forward declarations and #include <QMenuBar>
                      in your implementation file.

                    • Yes, indeed

                    No excuse to give, it's always good searching to understand what you are using :)

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post