Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Using qdoc to document classes within a namespace
Forum Update on Monday, May 27th 2025

Using qdoc to document classes within a namespace

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 4 Posters 4.8k Views
  • 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.
  • D Offline
    D Offline
    david1811
    wrote on last edited by
    #1

    Hello,

    I try to use qdoc to document a class which is within a namespace, and have the following problems:
    (just a preliminary remark: in my setup, everything works fine if I remove all the namespaces; I use qdoc in qt beta5 under osX).

    for example, I have a class Feature in a namespace xxx:
    @
    namespace xxx {
    class Feature {
    ...
    }
    }
    @
    I try to write a documentation for it:
    scenario 1:
    the class is a pure header class, thus I write a Feature.qdoc file, and add the following comment:
    @
    /*!
    \class Feature
    ...
    */
    @
    I get the error
    Cannot find 'Feature' specified with '\class' in any header file
    if I add 'using namespace xxx;' in the first line of the .qdoc file, nothing changes.

    Now, instead of using a .qdoc file, I use a .cpp file. The error disappears if I add 'using namespace xxx;'; still, if I refer to the class using \l{Feature} somewhere else, I get the error: Can't create link to 'Feature'

    scenario 2:
    same as above, but I link to the class using \l{xxx::Feature}. When running qdoc, it does not complain, but using the documentation, and clicking on the link, it tries to open a file named xxx-feature.html, which qdoc did not create (it does not exist).

    scenario 3:
    I use \class xxx::Feature instead of \class Feature in the source file, but the xxx-feature.html does not get generated.

    I googled quite some time, and did not find any answer. Is there a solution ? the only one I found was to remove the namespace, or to replace it with a macro which I add to the Cpp.ignoretokens (but for some reasons, this is not a good solution in my case)

    what are the best practices to document code with namespaces ??

    thanks, Dd

    1 Reply Last reply
    0
    • D Offline
      D Offline
      David Stiel
      wrote on last edited by
      #2

      Hi,

      It looks like the html output files (xxx-feature.html) are only generated if you describe the namespace (eg. in a separate .qdoc file):

      /*!
      \namespace publish

      bla bla bla
      

      */

      On a side note documentation of properties (\property ) only works if the Q_PROPERTY(...) declarations comes before any Q_ENUMS(...)

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        If you are not working on Qt itself, it's recommended to use Doxygen instead of qdoc. Just sayin' ;)

        (Z(:^

        1 Reply Last reply
        0
        • D Offline
          D Offline
          David Stiel
          wrote on last edited by
          #4

          Out of curiosity. Why do you recommended doxygen instead of qdoc. I was kind of intrigued by using the qdoc because it comes with Qt and can document Qt stuff like properties, signal, slots etc. But I’m sure you have your reasons… ;)

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

            QDoc is an internal Qt tool. It's possible to use it for external projects, but I'm not sure if it was intended for this purpose.

            Doxygen, on the other hand, was specifically designed to be used by external projects. It "understands Qt features":http://www.stack.nl/~dimitri/doxygen/manual/features.html like signals and slots.

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

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              As JKSH said, plus:

              • qdoc does not guarantee it's API, it is being modified between Qt releases and can simply break without notice
              • doxygen supports just soo much more: aparat from C++ and Qt with all it's features (including QML), it also understands Java, JavaScript and many others. It also supports different comment styles, and can produce much more output formats than qdoc (HTML, PDF, man pages, LaTeX, etc.)

              (Z(:^

              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