Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. What is the minimum code for a Qt project?
Qt 6.11 is out! See what's new in the release blog

What is the minimum code for a Qt project?

Scheduled Pinned Locked Moved Solved Qt 6
4 Posts 4 Posters 1.3k Views 3 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.
  • G Offline
    G Offline
    gouneken
    wrote on last edited by
    #1

    Good evening everyone, I'm writing because I have a problem compiling minimal code on Qt Creator. To create this project, I went to file> new file or project> other projects> empty project. chose the c ++ language and I created a main.cpp file in which I wrote the following code:
    #include <QApplication>
    int main(int &argc, char **argv[])
    {
    QApplication app(argc, argv);
    return app.exec();
    }

    But the compiler threw an error saying the file <QApplication> was not found, so I tried <QApplicationStateChangeEvent>. But then the compiler generated an error saying that the variable has an incomplete type "QApplication". And I don't know how to get the project to compile, please help me?

    raven-worxR JKSHJ 2 Replies Last reply
    0
    • G gouneken

      Good evening everyone, I'm writing because I have a problem compiling minimal code on Qt Creator. To create this project, I went to file> new file or project> other projects> empty project. chose the c ++ language and I created a main.cpp file in which I wrote the following code:
      #include <QApplication>
      int main(int &argc, char **argv[])
      {
      QApplication app(argc, argv);
      return app.exec();
      }

      But the compiler threw an error saying the file <QApplication> was not found, so I tried <QApplicationStateChangeEvent>. But then the compiler generated an error saying that the variable has an incomplete type "QApplication". And I don't know how to get the project to compile, please help me?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #4

      @gouneken said in What is the minimum code for a Qt project?:

      I went to file> new file or project> other projects> empty project.

      To clarify @SGaist's post: The option you want is File > New File or Project... > Application (Qt) > Qt Widgets Application

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

      1 Reply Last reply
      1
      • G gouneken

        Good evening everyone, I'm writing because I have a problem compiling minimal code on Qt Creator. To create this project, I went to file> new file or project> other projects> empty project. chose the c ++ language and I created a main.cpp file in which I wrote the following code:
        #include <QApplication>
        int main(int &argc, char **argv[])
        {
        QApplication app(argc, argv);
        return app.exec();
        }

        But the compiler threw an error saying the file <QApplication> was not found, so I tried <QApplicationStateChangeEvent>. But then the compiler generated an error saying that the variable has an incomplete type "QApplication". And I don't know how to get the project to compile, please help me?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #2

        @gouneken
        how does your pro/cmake file look like?
        maybe u jsut missing to add QtGui module?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #3

          Hi,

          To add to @raven-worx, it looks like you choose to start a non-Qt project rather than use one of the Qt specific project template hence your error.

          QApplication can be found in 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
          1
          • G gouneken

            Good evening everyone, I'm writing because I have a problem compiling minimal code on Qt Creator. To create this project, I went to file> new file or project> other projects> empty project. chose the c ++ language and I created a main.cpp file in which I wrote the following code:
            #include <QApplication>
            int main(int &argc, char **argv[])
            {
            QApplication app(argc, argv);
            return app.exec();
            }

            But the compiler threw an error saying the file <QApplication> was not found, so I tried <QApplicationStateChangeEvent>. But then the compiler generated an error saying that the variable has an incomplete type "QApplication". And I don't know how to get the project to compile, please help me?

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #4

            @gouneken said in What is the minimum code for a Qt project?:

            I went to file> new file or project> other projects> empty project.

            To clarify @SGaist's post: The option you want is File > New File or Project... > Application (Qt) > Qt Widgets Application

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

            1 Reply Last reply
            1

            • Login

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