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. Undeclared identifier QGridLayout

Undeclared identifier QGridLayout

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.6k 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.
  • O Offline
    O Offline
    ozzy
    wrote on last edited by
    #1

    i the header file <QtGui>, but the compiler note me that undeclared identifier QGridLayout

    #include <QtGui>
    QGridLayout *gridlayout = new QGridLayout;

    I know i include <QGridLayout> file can solve it.
    does it mean that if there are many widgets, i must include many header files ?

    kshegunovK raven-worxR 2 Replies Last reply
    0
    • O ozzy

      i the header file <QtGui>, but the compiler note me that undeclared identifier QGridLayout

      #include <QtGui>
      QGridLayout *gridlayout = new QGridLayout;

      I know i include <QGridLayout> file can solve it.
      does it mean that if there are many widgets, i must include many header files ?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @ozzy
      You're using Qt5, which means that you either have to do a full include of <QtWidgets> (widgets are in a separate module now) or include the QGridLayout's header explicitly (which is the better way in my opinion).

      You also might need to add the widgets module to your .pro file, if not done already, like this:
      QT += widgets.

      Kind regards.

      Read and abide by the Qt Code of Conduct

      O 1 Reply Last reply
      0
      • O ozzy

        i the header file <QtGui>, but the compiler note me that undeclared identifier QGridLayout

        #include <QtGui>
        QGridLayout *gridlayout = new QGridLayout;

        I know i include <QGridLayout> file can solve it.
        does it mean that if there are many widgets, i must include many header files ?

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

        @ozzy
        to add to @kshegunov post:
        In case you are unsure in which module the class is contained you can quickly check on the very top of the related doc page.

        --- 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
        1
        • kshegunovK kshegunov

          @ozzy
          You're using Qt5, which means that you either have to do a full include of <QtWidgets> (widgets are in a separate module now) or include the QGridLayout's header explicitly (which is the better way in my opinion).

          You also might need to add the widgets module to your .pro file, if not done already, like this:
          QT += widgets.

          Kind regards.

          O Offline
          O Offline
          ozzy
          wrote on last edited by
          #4

          @kshegunov

          my.pro file contain the sentence: greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
          i change #include <QtGui> to #include <QtWidgets> everything works well.
          Thank you ~

          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