Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Solved Can't import QApplication?

    General and Desktop
    2
    7
    100
    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.
    • M
      Miixtar last edited by

      Heyya!

      I was just kicking of a new project so started by writing the usual basic code, nothing fancy:

      #include <QApplication>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          return app.exec();
      }
      
      

      And I get an error telling me " 'QApplication' file not found ". I have absolutely no idea why it would do that, it's the first time is does that.
      I tried opening a qt project with MSVC recently, I doubt that would be the reason, but who knows?

      I know I could include it from my c:\Qt file, but IDK where it is, and it would be very anoying to have to do that for every #include.

      Please help!

      Do ask away for any info needed! I thank you already for the help you might provide!

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

        Hi,

        Do you have

        QT += widgets
        

        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 1
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi,

          Do you have

          QT += widgets
          

          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 1
          • M
            Miixtar last edited by

            I hadn't put it yet, but when I added it, nothing changed! And QApplication isn't a widget anyway is it?

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

              Did you re-run qmake after modifying the .pro file ?

              It's part of the widgets module.

              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
              • M
                Miixtar last edited by

                All good, thx.... I realy didn't think QApplication was considered a widget... sorry for asking such a stupid question .. hehe... well thanks!

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

                  It is not a widget, it is part of the widgets module because it is responsible of setting the connection with the window manager and other stuff like that.

                  Being in the widgets module does not mean that every class in there is a QWidget.

                  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 1
                  • M
                    Miixtar last edited by

                    Right! Thanks

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