Creating Links

These commands are for creating hyperlinks to classes, functions, examples, and other targets.

The \l link command is used to create a hyperlink to many different kinds of targets. The command's general syntax is:

\l {link target} {link text}
 / *!
    Read the \l {http://qt-project.org/doc/qt-5.0/}
    {Qt 5.0 Documentation} carefully.
 * /

QDoc renders this as:

Read the Qt 5.0 Documentation carefully.

If the link target is equivalent to the link text, the second argument can be omitted.

For example, if you have documentation like:

/ *!
   \target assertions

   Assertions make some statement about the text at the
   point where they occur in the regexp, but they do not
   match any characters.

   ...

   Regexps are built up from expressions, quantifiers, and
   \l {assertions} {assertions}.
* /

You can simplify this as follows:

/ *!
  \target assertions

  Assertions make some statement about the text at the
  point where they occur in the regexp, but they do not
  match any characters.

  ...

  Regexps are built up from expressions, quantifiers, and
  \l assertions.
* /

For the one-parameter version, the braces can often be omitted. The \l command supports several ways of linking:

  • \l QWidget - The name of a class documented with the \class command.
  • \l QWidget::sizeHint() - The name of a member function, documented with or without an \fn command.
  • \l <QtGlobal> - The subject of a \headerfile command.
  • \l widgets/wiggly - The relative path used in an \example command.
  • \l {QWidget Class Reference} - The title used in a \title command.
  • \l {Introduction to QDoc}- The text from one of the \part, \chapter, or \section commands.
  • \l fontmatching - The argument of a \target command.
  • \l {Shared Classes} - A keyword named in a \keyword command.
  • \l http://qt-project.org/ - A URL.

QDoc also tries to make a link out of any word that doesn't resemble a normal English word, for example, Qt class names or functions, like QWidget or QWidget::sizeHint(). In these cases, the \l command can actually be omitted, but by using the command, you ensure that QDoc will emit a warning if it cannot find the link target. In addition, if you only want the function name to appear in the link, you can use the following syntax:

  • \l {QWidget::} {sizeHint()}

QDoc renders this as:

sizeHint()

See also \sa, \target, and \keyword.

\sa (see also)

The \sa command defines a list of links that will be rendered in a separate "See also" section at the bottom of the documentation unit.

The command takes a comma-separated list of links as its argument. If the line ends with a comma, you can continue the list on the next line. The general syntax is:

\sa {the first link}, {the second link},
    {the third link}, ...

QDoc will automatically try to generate "See also" links interconnecting a property's various functions. For example, a setVisible() function will automatically get a link to visible() and vice versa.

In general, QDoc will generate "See also" links that interconnect the functions that access the same property. It recognizes four different syntax versions:

  • property()
  • setProperty()
  • isProperty()
  • hasProperty()

The \sa command supports the same kind of links as the \l command.

  / *!
     Appends the actions \a actions to this widget's
     list of actions.

     \sa removeAction(), QMenu, addAction()
  * /
  void QWidget::addActions(QList<QAction *> actions)
  {
  ...
  }

QDoc renders this as:

void QWidget::addActions ( QList<QAction*> actions )

Appends the actions actions to this widget's list of actions.

See also removeAction(), QMenu, and addAction().

See also \l, \target and \keyword.

\target

The \target command names a place in the documentation that you can link to using the \l (link) and \sa (see also) commands.

The text up to the line break becomes the target name. Be sure to follow the target name with a line break. Curly brackets are not required around the target name, but they may be required when the target name is used in a link command. See below.

/ *!
    \target capturing parentheses
    \section1 Capturing Text

    Parentheses allow us to group elements together so that
    we can quantify and capture them.

    ...
* /

The target name capturing parentheses can be linked from within the same document containing the target in the following way:

  • \l {capturing parentheses} (from within the same QDoc comment)

Note: The brackets in the link example are required because the target name contains spaces.

See also \l, \sa and \keyword.

\keyword

The \keyword command names a place in the documentation that you can link to using the \l (link) and \sa (see also) commands.

The \keyword command is like the \target command, but stronger. A keyword can be linked from anywhere using a simple syntax.

Keywords must be unique over all the documents processed during the QDoc run. The command uses the rest of the line as its argument. Be sure to follow the keyword with a line break.

/ *!
    \class QRegExp
    \reentrant
    \brief The QRegExp class provides pattern
           matching using regular expressions.
    \ingroup tools
    \ingroup misc
    \ingroup shared
    \mainclass

    \keyword regular expression

    Regular expressions, or "regexps", provide a way to
    find patterns within text.

    ...
* /

The location marked with the keyword can be linked to with:

/ *!
    When a string is surrounded by slashes, it is
    interpreted as a \l {QRegExp}{regular expression}.
* /

QDoc renders this as:

When a string is surrounded by slashes, it is interpreted as a regular expression.

If the keyword text contains spaces, the brackets are required.

See also \l (link), \sa (see also) and \target.

© 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.