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. No such file or directory #include <QtWidgets>
Forum Updated to NodeBB v4.3 + New Features

No such file or directory #include <QtWidgets>

Scheduled Pinned Locked Moved General and Desktop
15 Posts 5 Posters 17.1k 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.
  • X Offline
    X Offline
    Xander84
    wrote on last edited by
    #5

    you have to include the Qt classes you need, for a simple program like this you can include the whole module but I would not recommend that because it will drastically increase compile time.
    @
    #include <QApplication>
    #include <QWidget>
    #include <QPushButton>
    @
    essentially you have to include all Qt classes like this, if you want to do it right. :)

    if you are lazy or have a super fast computer you can include whole Qt modules at once with
    @
    #include <QtCore>
    #include <QtGui>
    #include <QtWidgets>
    ...
    @
    i would only use that if you need many classes from one module.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tymop
      wrote on last edited by
      #6

      Thank you,
      with your help, I managed to run the example.

      I find it unfortunate that the examples do not work as they are.
      That make the learning more difficult.

      1 Reply Last reply
      1
      • C Offline
        C Offline
        clochydd
        wrote on last edited by
        #7

        Usually, the examples work as they are.
        I have opened your examples/widgets/tutorials/addressbook/part1 with the Qt Creator, built it and had no errors.
        How did you work with the example?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tymop
          wrote on last edited by
          #8

          That is strange, because, as I said, I just install qtcreator with the script qt-opensource-linux-x64-1.5.0-2-online.run, in the /opt directory/

          Then, I open it and tried some examples, and I have the same problem eact time.

          1 Reply Last reply
          1
          • X Offline
            X Offline
            Xander84
            wrote on last edited by
            #9

            Do you open the examples from Qt creator directly? (Welcome -> examples)
            they should work out of the box.

            And is there a reason you use and old version of Qt? I mean that is like 2 years old or something. :)

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tymop
              wrote on last edited by
              #10

              Do you open the examples from Qt creator directly? No : I opened with open file or project

              And is there a reason you use and old version of Qt? I used the version found on the site web qt-opensource-linux-x64-1.5.0-2-online.run

              I tried another version comming from the ubuntu deposite(Qt Creator 3.0.1) , but there was another problem because the binary /usr/bin/qmlpuppet was not installed (because not in the ubuntu deposite), and I did not find he way to install it.

              1 Reply Last reply
              0
              • X Offline
                X Offline
                Xander84
                wrote on last edited by
                #11

                I have Qt 5.2.1 running on my Ubuntu machine, using the online installer (qt-linux-opensource-1.5.0-x64-online.run in my case), worked like a charm so I don't know what you did. You have so weird bugs, I have no idea why, sorry.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  clochydd
                  wrote on last edited by
                  #12

                  I think we should try to find out, what happend to your install.
                  If you look at your Creator's About screen, do you see this:
                  Qt Creator 3.1.0 (opensource)
                  Based on Qt 5.2.1 (GCC 4.6.1, 64 bit)
                  Try to compare your Creator settings with "this: ":http://qt-project.org/doc/qtcreator-3.1/creator-configuring.html

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tymop
                    wrote on last edited by
                    #13

                    Thank form your help.
                    This is the version installed
                    @Qt Creator 3.0.1
                    Based on Qt 5.2.1 (GCC 4.8.2, 64 bit)
                    Built on Apr 9 2014 at 09:12:59
                    @

                    And the version from the .run
                    @Qt Creator 3.1.0 (opensource)
                    Basé sur Qt 5.2.1 (GCC 4.6.1, 64 bit)
                    Compilé le Apr 14 2014 à 15:03:42
                    Depuis la révision 52592aa879@

                    But it is strange because, now, the qtcreator installed from the unbuntu deposites is now working. Maybe the .run install added the missing files ?

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      clochydd
                      wrote on last edited by
                      #14

                      As the Qt Creator 3.1.0 is the newest version it would be better to use it instead of 3.0.1 - but if you succeed with 3.0.1 you shouldn't have problems.
                      Perhaps you may give 5.3.0 a try when it's released in a few days.

                      1 Reply Last reply
                      0
                      • T tymop

                        Hello,
                        I am a beginner with qt, and I just download and install the last vesion of qt with this link "qt-opensource-linux-x64-1.5.0-2-online.run":http://download.qt-project.org/official_releases/online_installers/qt-opensource-linux-x64-1.5.0-2-online.run

                        Then, I tried some examples to understand how qt works, but i have the save error with each examle I tried. This is an example
                        @/opt/qt/5.2.1/gcc_64/examples/widgets/tutorials/addressbook/part1/addressbook.cpp:41: erreur : QtWidgets: No such file or directory
                        #include <QtWidgets>@

                        always the same error : @erreur : QtWidgets: No such file or directory #include <QtWidgets>@

                        Is there anything especial to do to work with the examples ?

                        what is the problem ?

                        Thank a lot for your help.

                        A Offline
                        A Offline
                        AlexeiK
                        wrote on last edited by
                        #15

                        @tymop
                        Провести настройку комплектов под Qt5
                        На вкладке Проекты провести настройку проекта заново с верными компеляторами

                        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