qt-qml-docs
Document QML types, properties, signals, and modules with QDoc for Qt6 QML modules.
Files1
View on GitHubSKILL.mddocs/skills/qt-qml-docs/SKILL.md
GitHubWhen to use
You are writing QDoc comments for QML types (in .cpp/.h backing a QML type, or in .qml/.qdoc files) and want correctly linked, buildable API reference pages. Reach here when the goal is documentation output.
Not for: writing the QML itself (use qt-qml) or reviewing QML for defects and performance (use qt-qml-review).
Method
- Open each type with
\qmltypeand place it in a module with\inqmlmodule. Decision point: if the QML type is backed by a C++ class, add\nativetype <Class>(Qt 6.6+; older Qt uses\instantiates) so the pages cross-link. - Document every public property with
\qmlproperty <type> <name>. Decision point: if the property is init-only mark\readonly; if it is the type's default property mark\default. - Document signals with
\qmlsignal, invokable methods with\qmlmethod, and attached properties with\qmlattachedproperty. Decision point: if a member exists only on an attached type, use the attached variants so it renders under the attaching type. - Version each addition with
\since QtQuick 6.x. Decision point: if a member arrived in a later minor release than the type, put\sinceon the member, not the type. - Cross-link with
\saand inline\l. Decision point: if you reference another module's type, link the fully qualified name so QDoc resolves across modules. - Configure the module's
.qdocconfto scan QML sources and register the module, then build withqdoc.
Example
/*!
\qmltype BackendModel
\inqmlmodule Demo
\nativetype BackendModel
\brief Holds and mutates the demo counter.
\section1 Usage
\qml
BackendModel { id: model }
Text { text: model.count }
\endqml
*/
/*!
\qmlproperty int BackendModel::count
\readonly
The current counter value. Emits \l countChanged on update.
\sa increment
*/
/*!
\qmlmethod void BackendModel::increment()
\since QtQuick 6.5
Increments \l count by one.
*/
/*!
\qmlsignal BackendModel::countChanged()
Emitted whenever \l count changes.
*/
Pitfalls
- Missing \inqmlmodule. Without it QDoc cannot place the type in a module and the page is orphaned / links break.
- Wrong backing command.
\instantiatesis legacy; on Qt 6.6+ use\nativetypeto link the QML type to its C++ class (and vice-versa). - Type-and-name mismatch.
\qmlpropertyneeds<type> <TypeName>::<prop>; omitting the type or the qualifier breaks resolution and the property renders untyped. - Undocumented enums. Enums exposed to QML need their own doc block with each value listed via
\value, or they render blank. - Signal vs handler confusion. Document the signal with
\qmlsignal; QDoc auto-generates theon<Signal>handler entry — do not document the handler separately. - qdocconf not scanning QML. If
.qml/headers aren't in the source/header dirs, QML types silently never appear.
Output format
/*!
\qmltype <TypeName>
\inqmlmodule <Module>
\nativetype <BackingClass> // if C++-backed
\since QtQuick 6.x
\brief <one line>.
<description, optionally with \qml ... \endqml or \code ... \endcode>
*/
/*!
\qmlproperty <type> <TypeName>::<prop>
\readonly // if applicable
\default // if default property
<description> \sa <related>
*/
Reference
- Core commands:
\qmltype,\qmlproperty,\qmlsignal,\qmlmethod,\qmlattachedproperty,\qmlattachedsignal— declare the documented QML members. - Module placement:
\inqmlmodule <Module>assigns the type to its QML module; must match the URI inqt_add_qml_module. - C++ linking:
\nativetype <Class>(Qt 6.6+) links QML type ⇄ backing C++ class; the older\instantiates <Class>command does the same on pre-6.6 and is now deprecated. - Property syntax:
\qmlproperty <type> <TypeName>::<name>— the type and theTypeName::qualifier are both required. Modifiers:\readonly,\default,\required. - Enums: document an enum exposed to QML with a doc block and one
\value <Name> <desc>per enumerator; expose from C++ viaQ_ENUM/QML_ELEMENTon the enclosing type. - Versioning:
\since QtQuick 6.x(or\since <Module> 6.x) marks the introducing release; place on the member if later than the type. - Cross-links:
\safor "See also" lists;\l <Type>/\l {Module::Type}for inline links;\brieffor the summary line. - Code blocks:
\qml ... \endqmlfor QML snippets (syntax-highlighted as QML),\code ... \endcodefor generic/C++ code. - qdocconf: set
sourcedirs/headerdirsto include the QML module's sources, list the module underqhpconfig, and setoutputdir; runqdoc <project>.qdocconf(or viaqt_add_docs/qt_generate_qml_docsin CMake).