用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/qt/qtqa --skill skill-module-export命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| 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)