Qt Forum

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

    Forum Updated on Feb 6th

    Unsolved Misleading header names

    General and Desktop
    4
    5
    1064
    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.
    • A
      Amomum last edited by

      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'.

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

        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 Reply Quote 0
        • JKSH
          JKSH Moderators @Amomum last edited by

          @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 Reply Quote 0
          • A
            Amomum @JKSH last edited by

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

            1 Reply Last reply Reply Quote 0
            • kshegunov
              kshegunov Moderators last edited by

              @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 Reply Quote 0
              • First post
                Last post