Using automatic documentation of my own function with Qt Creator?

Cory Klein picture Cory Klein · Jul 30, 2013 · Viewed 25.1k times · Source

I was using Qt Creator and I decided I wanted to document a function I had written so I positioned my cursor above my function definition and typed /**<ENTER> like so:

/**<ENTER>
void MyClass::myFunction(int myArg)
{
...

Qt Creator auto-expanded that comment:

/**
 * @brief MyClass::myFunction
 * @param myArg
 */
void MyClass::myFunction(int myArg)
{
...

What is this? Where is it documented?

Can I use this to generate my own Qt Assistant qch help files or something?

Answer

phyatt picture phyatt · Jul 30, 2013

It should be documented here or here, but its not...

So here is some info about it:

The settings for this feature are found here:

Windows:

Qt Creator > Tools > Options > Text Editor > Completion > Documentation Comments

Mac OS X:

Qt Creator > Preferences > Text Editor > Completion > Documentation Comments

The three options it lists are:

  • Enable doxygen blocks
  • Generate brief description
  • Add leading asterisks

(Found in Qt 2.6, but possibly in earlier versions, too?, or it may be part of the default plugin set at some point.)

The stubs that are created are doxygen style stubs.

You can use doxygen to run through your source code and create some fancy documentation, both in a chm file and in a html document and pdf.

http://www.doxygen.nl/

http://www.doxygen.nl/manual/output.html (includes qch files)

Here is a related plugin for Qt Creator:

http://dev.kofee.org/projects/qtcreator-doxygen/wiki

And using the QHelpEngine in your own program...

http://qt-project.org/doc/qt-4.8/qthelp-framework.html

And finally, you can use QDesktopServices to handle a help styled url:

http://doc-snapshot.qt-project.org/4.8/qdesktopservices.html#url-handlers

Hope that helps.