一键导入
skill-module-export
Reference for Qt C++ export macros and QML registration macros that indicate public APIs requiring documentation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Reference for Qt C++ export macros and QML registration macros that indicate public APIs requiring documentation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Qt documentation products, modules, repository structure, and API types. Apply when working with Qt documentation, resolving module names, or understanding Qt's documentation ecosystem.
Authoritative style rules for writing accessibility alt text in Qt documentation, including priority order, formatting rules, and terminology guidelines. Use when adding alt text to images.
Cross-product impact checking for Qt documentation changes. Load this skill whenever a doc change (page rename, title change, filename change, API rename, QML type rename) may affect products outside the changed module. Covers all doc.qt.io products, all doc-snapshots.qt.io products, and qt.io marketing pages. Provides verified snapshot paths, index file availability, link mechanisms per product, and search procedures in priority order. Use alongside doc-impact-analyzer Steps 5–6 or standalone when auditing cross-product reference breakage.
Structured findings report format shared by doc-structure-auditor and doc-impact-analyzer. Covers severity levels, finding types, summary tables, validation blocks, notes, and verdicts.
Reference for the Qt Doc Team diff format - generic feedback and recommendation template with validation and approval workflow
Language, grammar, and style guidelines for Qt documentation including active voice, terminology, QUIP 25 standards, and proper API documentation patterns. Covers both WHAT to write (style/content) and HOW to write it (QDoc syntax).
| name | skill-module-export |
| description | Reference for Qt C++ export macros and QML registration macros that indicate public APIs requiring documentation |
| metadata | {"version":"1.4"} |
This reference documents Qt export macros that indicate symbol visibility. Export macros alone do NOT determine whether a class should be \internal - context matters.
Documentation agents use this reference to:
\internal is valid (common pattern)Export macro + \internal is VALID for:
QWidgetPrivate, QObjectPrivate)_p.h headers exported for cross-module internal useExport macro WITHOUT \internal required for:
No export macro = truly internal:
\internal documentationMost frequently used:
Q_CORE_EXPORT - QtCore classesQ_GUI_EXPORT - QtGui classesQ_WIDGETS_EXPORT - QtWidgets classesQ_NETWORK_EXPORT - QtNetwork classesQ_QML_EXPORT - QtQml classesQ_QMLCOMPILER_EXPORT - QtQmlCompiler classesQ_QUICK_EXPORT - QtQuick classesQ_QUICKCONTROLS2_EXPORT - QtQuickControls classesQ_QUICKTEMPLATES2_EXPORT - QtQuickTemplates classesQ_SQL_EXPORT - QtSql classesQ_MULTIMEDIA_EXPORT - QtMultimedia classesQ_WEBENGINE_EXPORT - QtWebEngine classesOthers: 70+ additional macros for Qt modules (3D, Charts, Sensors, etc.)
Complete list: See qt6/qtbase/src/corelib/global/qglobal.h and module export headers
Most Qt modules follow the pattern:
Q_<MODULE>_EXPORT
Where <MODULE> is the uppercase module name without "Qt" prefix:
Q_CORE_EXPORTQ_QUICK_EXPORTQ_MULTIMEDIA_EXPORTExport macros appear between class keyword and class name:
class Q_CORE_EXPORT QObject // <- Public API
{
Q_OBJECT
...
};
class QObjectPrivate // <- No export macro = internal
{
...
};
Some classes use Q_GADGET_EXPORT instead of class-level export macros:
class Any final : public QProtobufMessage
{
Q_GADGET_EXPORT(Q_PROTOBUFWELLKNOWNTYPES_EXPORT)
Q_PROPERTY(QString typeUrl READ typeUrl WRITE setTypeUrl)
...
};
Key differences from class export:
Q_GADGET instead of Q_OBJECTDetection pattern:
Q_GADGET_EXPORT\s*\(\s*(Q_\w+_EXPORT)\s*\)
Examples:
Q_GADGET_EXPORT(Q_PROTOBUFWELLKNOWNTYPES_EXPORT) - QtProtobuf typesQ_GADGET_EXPORT(Q_CORE_EXPORT) - Core value typesThis is a VALID, well-established pattern in Qt. Many classes have both export macros and \internal tags. This is NOT a conflict to be avoided.
// Header: Q_GUI_EXPORT for cross-module visibility
class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
// Documentation: \internal = excluded from app-developer docs
/*!
\class QWidgetPrivate
\inmodule QtWidgets
\internal
*/
Why this pattern exists:
\internal hides from public documentationExisting examples in Qt (18+ classes):
| Module | Examples |
|---|---|
| QtCore | QAbstractItemModelPrivate, QPropertyBindingPrivate |
| QtGui | QFileSystemModelPrivate, QPointingDevicePrivate, QShortcutPrivate |
| QtWidgets | QWidgetPrivate, QGraphicsItemPrivate |
| QtQml | QQmlComponentPrivate, QQmlPropertyCache, QQmlNotifier |
When to use export + internal:
*Private)_p.h headers needed by other modulesImpact on links:
\internal excludes class from public documentation index\c for code formatting instead of \l for links to internal classes\internal (see "Export + Internal Pattern")_p.h headers - Usually \internal, even with export macros\internal (for platform plugins, not app developers)Workflow:
.h) + public class name → app developers_p.h) OR *Private class → internal useQPlatform*) → platform plugin developers\class documentation required\class, \inmodule, \internal is correctDecision tree:
Is it a *Private class or in _p.h header?
├─ YES → Use \internal (even with export macro)
└─ NO → Is it a QPA class (QPlatform*)?
├─ YES → Use \internal (even with export macro)
└─ NO → Is it in a public header?
├─ YES → Full documentation required
└─ NO → Use \internal
Examples:
class QWidgetPrivate : public QObjectPrivate // <- *Private class, use \internal
class Q_GUI_EXPORT QPlatformWindow // <- QPA class, use \internal
class Q_QUICK_EXPORT QQuickItem : public QObject // <- Public API, full docs
class QInternalClass : public QObject // <- No export, use \internal
Class export (before class name):
class\s+(Q_\w+_EXPORT|QT\w+_EXPORT|QAXCONTAINER_EXPORT|QAXSERVER_EXPORT)\s+\w+
Gadget export (inside class body):
Q_GADGET_EXPORT\s*\(\s*(Q_\w+_EXPORT)\s*\)
Matches:
class Q_CORE_EXPORT QObjectclass Q_QUICK_EXPORT QQuickItemclass QT3DCORE_EXPORT QEntityQ_GADGET_EXPORT(Q_PROTOBUFWELLKNOWNTYPES_EXPORT)Not export macros:
Q_OBJECT, Q_GADGET, Q_NAMESPACE (meta-object macros, not exports)Q_DECLARE_FLAGS, Q_ENUM (not exports)Decision Tree:
Is it a *Private class, in _p.h, or a QPA class?
├─ YES → \internal is correct (even with export macro)
└─ NO → Is it in a public header with export macro?
├─ YES → Full documentation required (app developer API)
└─ NO → \internal is correct
Key Points:
\internal is a VALID, common pattern (18+ existing cases)*Private classes, QPA classes, and _p.h classes are internalClasses can be exposed to QML using registration macros. These indicate that a QML type needs documentation.
| Macro | Purpose | QDoc Command |
|---|---|---|
QML_ELEMENT | Expose class to QML (same name) | \qmltype ClassName |
QML_NAMED_ELEMENT(Name) | Expose with custom QML name | \qmltype Name |
QML_VALUE_TYPE(name) | Expose Q_GADGET as value type | \qmlvaluetype name |
QML_UNCREATABLE("reason") | Abstract type, can't instantiate | Add note in docs |
QML_SINGLETON | Singleton in QML | Document as singleton |
QML_ANONYMOUS | Register but don't expose by name | Usually no docs needed |
QML_FOREIGN(Type) | Register another type | Docs on foreign type |
QML_ATTACHED(Type) | Provides attached properties | \qmlattachedproperty |
QML_ADDED_IN_VERSION(M, N) | Version when added | \since |
| Command | Purpose |
|---|---|
\qmltype TypeName | Documents QML type |
\qmlvaluetype typename | Documents QML value type (lowercase!) |
\nativetype ClassName | Links QML type to backing C++ class |
\inqmlmodule ModuleName | Associates with QML module |
\qmlproperty type Type::prop | Documents QML property |
\qmlsignal Type::signalName() | Documents QML signal |
\qmlmethod Type::methodName() | Documents QML method |
When a class has BOTH C++ export macro AND QML registration, it may need separate documentation for each API:
Example: QQuick3DTextureData
// Header (public - qquick3dtexturedata.h)
class Q_QUICK3D_EXPORT QQuick3DTextureData : public QQuick3DObject
{
Q_OBJECT
QML_NAMED_ELEMENT(TextureData)
QML_UNCREATABLE("TextureData is Abstract")
...
};
Documentation has TWO blocks:
/*!
\qmltype TextureData
\nativetype QQuick3DTextureData
\inqmlmodule QtQuick3D
\brief Base type for custom texture data.
...
*/
/*!
\class QQuick3DTextureData
\inmodule QtQuick3D
\brief Base class for defining custom texture data.
...
*/
| Header | Export? | QML Macro? | C++ Docs | QML Docs |
|---|---|---|---|---|
| Public (.h) | Yes | Yes | \class required | \qmltype required |
| Public (.h) | Yes | No | \class required | N/A |
| Public (.h) | No | Yes | Optional | \qmltype required |
| Private (_p.h) | Yes | Yes | Usually skip* | \qmltype required |
| Private (_p.h) | Yes | No | \internal or skip | N/A |
| Private (_p.h) | No | No | \internal or skip | N/A |
*Export in private header = internal Qt module use; C++ class docs usually omitted.
\nativetype Command\nativetype in a \qmltype block links QML documentation to its C++ backing class:
/*!
\qmltype WebChannel
\nativetype QQmlWebChannel // <-- Links to C++ class
\inqmlmodule QtWebChannel
\brief QML interface to QWebChannel.
*/
Key points:
\nativetype does NOT create C++ class documentation\class blockWarning:
No output generated for property 'QFoo::bar' because 'QFoo' is undocumented
Cause: \property QFoo::bar exists but no \class QFoo documentation.
Fix options:
\class QFoo documentation (if public C++ API)\property docs (if QML-only API, \qmlproperty suffices)QML Object Types (inherit QObject):
QML_ELEMENT or QML_NAMED_ELEMENT\qmltype TypeName (PascalCase)QML Value Types (Q_GADGET):
QML_VALUE_TYPE(name)\qmlvaluetype typename (lowercase!)\qmlvaluetype geoCoordinate (not GeoCoordinate)QML registration (any of these = needs QML docs):
QML_ELEMENT|QML_NAMED_ELEMENT\s*\(|QML_VALUE_TYPE\s*\(|QML_SINGLETON
Full public API (both C++ and QML docs needed):
_p.h)Q_QUICK3D_EXPORT)