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. Trouble in #include<QtGui> or #include<QtCore>
Forum Updated to NodeBB v4.3 + New Features

Trouble in #include<QtGui> or #include<QtCore>

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 4.2k 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.
  • Q Offline
    Q Offline
    qt_newbie89
    wrote on last edited by
    #1

    Hello everybody,

    I am learning Qt programming and confused by the include of QtGui and QtCore with Qt 5.0 SDK.
    In the book C++Qt programming with Qt 4 2nd Edition, it said that if we want to use components such as QCheckBox, QLineEdit, QPushButton or QLabel, we only need to include QtGui at the beginning instead of include individual headers <QCheckBox>, <QLineEdit> etc...
    I tried but it throwed a bunch of errors "no appropriate default constructor available". The problem is only solved by include the individual headers.
    Could any body help me figure out the problem? Me or Qt5.0 has changed that we need to include individually.

    Thanks very much.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Qt5 moved a few things around. You need to:
      @
      #include <QtWidgets>
      @

      to include everything or, preferably to minimise build times in 'real' projects :
      @
      #include <QCheckBox>
      #include <QLineEdit>
      // etc.
      @

      You will also need:
      @
      QT += widgets
      @

      in your PRO file.

      Not much else has changed in the widgets.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kdk85
        wrote on last edited by
        #3

        Thank you ChrisW67, your suggestion solved the problem, one a side note is there a link for viewing differences on how to 'include' files when qt5.0 is used.

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

          Hi kdk85,

          Details about differences between Qt 4 and Qt 5 are in the porting guide: http://qt-project.org/doc/qt-5.0/qtdoc/portingguide.html There are a few different pages, so make sure you read all the "related topics" listed.

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

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kdk85
            wrote on last edited by
            #5

            Thank you JKSH for providing the link

            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