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. Misleading header names

Misleading header names

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.4k Views 4 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.
  • A Offline
    A Offline
    Amomum
    wrote on last edited by
    #1

    I'm not sure that's even a problem but I have to ask anyway.
    Qt provides extensionless header files like Qlist or QtCore. Interesting fact is that a lot of them contain just one line:
    QObject is "#include "qobject.h"
    QApplication is "#include "qapplication.h"
    QTimer is "#include "qtimer.h"
    and so on. I don't know why this is done like that but no matter.

    My question is: why file QMetaObject does not include qmetaobject.h but includes qobjectdefs.h?
    I spent quite some time trying to figure out why I have only forward declaration of 'class QMetaEnum'.

    JKSHJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      In doc, it lists the header to use for a an object
      like
      Header: #include <QMetaObject>

      So using "internal" names like qapplication.h might lead to surprises like u seen with meta system.

      I guess with such big framework, some inconsistencies will exists :)

      1 Reply Last reply
      0
      • A Amomum

        I'm not sure that's even a problem but I have to ask anyway.
        Qt provides extensionless header files like Qlist or QtCore. Interesting fact is that a lot of them contain just one line:
        QObject is "#include "qobject.h"
        QApplication is "#include "qapplication.h"
        QTimer is "#include "qtimer.h"
        and so on. I don't know why this is done like that but no matter.

        My question is: why file QMetaObject does not include qmetaobject.h but includes qobjectdefs.h?
        I spent quite some time trying to figure out why I have only forward declaration of 'class QMetaEnum'.

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

        @Amomum said:

        I don't know why this is done like that but no matter.

        Because it's easier for users to #include the class names. No need to remember the separate header filenames.

        My question is: why file QMetaObject does not include qmetaobject.h but includes qobjectdefs.h?
        I spent quite some time trying to figure out why I have only forward declaration of 'class QMetaEnum'.

        That looks like a bug. Could you please submit a report to https://bugreports.qt.io/ ?

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

        A 1 Reply Last reply
        0
        • JKSHJ JKSH

          @Amomum said:

          I don't know why this is done like that but no matter.

          Because it's easier for users to #include the class names. No need to remember the separate header filenames.

          My question is: why file QMetaObject does not include qmetaobject.h but includes qobjectdefs.h?
          I spent quite some time trying to figure out why I have only forward declaration of 'class QMetaEnum'.

          That looks like a bug. Could you please submit a report to https://bugreports.qt.io/ ?

          A Offline
          A Offline
          Amomum
          wrote on last edited by
          #4

          @JKSH sure. I have submitted here https://bugreports.qt.io/browse/QTBUG-50643

          1 Reply Last reply
          0
          • kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @JKSH said:

            That looks like a bug.

            I beg to differ.

            @Amomum, if you take a peek at the documentation of QMetaObject you'll notice that QMetaEnum is only used as a return type, so by using only the forward declaration Qt developers ensured minimal number of includes. If you need to use QMetaEnum just include that header in your code, no need to burden the compiler with headers that are not needed for compilation.

            Kind regards.

            Read and abide by the Qt Code of Conduct

            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