- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
自从从 Qt 5.10 升级到 Qt 5.11 后,我开始无法生成带有 QDoc 的文档。对于我现有的项目。
许多问题之一是文档中缺少函数,尽管源代码中存在相应的注释。
我已设法将问题缩小到包含 Q_OBJECT
宏,如提供的代码示例所示(见下文)。
Qt documentation中确实提到了这一点:
If not specified by the
Cpp.ignoretokens
orCpp.ignoredirectives
variables, non-standard constructs (typically macros) can result in erroneous documentation.
Q_OBJECT
不应该引起问题,因为它写得更远一点:
The
Q_OBJECT
macro, however, is an exception: QDoc recognizes this particular non-standard construct, so there is no need specifying it using theCpp.ignoredirectives
variable.
无论如何我都会包含qt-cpp-defines.qdocconf
在我的 qdocconf
文件中。
我还尝试手动将Q_OBJECT
添加到忽略列表
Cpp.ignoredirectives += Q_OBJECT
但结果是一样的。
我在 Windows 10 和 Ubuntu 17 下遇到了上述问题。Under Windows 7 I cannot execute qdoc.exe
at all .
解决此问题的 qdocconf
的正确配置是什么?
为了快速重现(在真实情况下,声明和实现是分开的,并添加了适当的注释),请考虑以下设置:
Foo.h
#include <QObject>
class Foo : public QObject
{
// Q_OBJECT // <-- uncomment this to break QDoc
public:
Foo() {}
void boo() {}
protected:
void moo() {}
};
Foo.cpp
#include "Foo.h"
/*!
\class Foo
*/
test.qdocconf
include($QT_INSTALL_DOCS/global/compat.qdocconf)
include($QT_INSTALL_DOCS/global/fileextensions.qdocconf)
include($QT_INSTALL_DOCS/global/qt-cpp-defines.qdocconf)
include($QT_INSTALL_DOCS/global/macros.qdocconf)
# Uncoment this for a test
# Cpp.ignoredirectives += Q_OBJECT
outputdir = html
headerdirs = .
sourcedirs = .
exampledirs = .
imagedirs = ./images
Q_OBJECT
)执行 qdoc.exe test.qdocconf
我或多或少得到以下信息:
- Foo
Contents
- Public Functions
- Protected Functions
- Detailed Description
Foo Class
- List of all members, including inherited members
Public Functions
Foo()
void boo()
Protected Functions
void moo()
Detailed Description
Member Function Documentation
Foo::Foo()
Default constructs an instance of Foo.
void Foo::boo()
[protected] void Foo::moo()
Q_OBJECT
)取消注释 Q_OBJECT
宏并再次运行 qdoc.exe
会产生以下结果:
- Foo
Contents
- Detailed Description
Foo Class
Detailed Description
重要提示:Foo
、moo
和boo
都不见了。
最佳答案
我知道这个问题已经有几年了,但我想为找到这个问题的 future 搜索者发布一个答案。我的 .cpp 文件中的 Q_OBJECT 和 Q_INVOKABLE 宏都遇到了这个问题。
解决方案是在您的 .qdocconf 文件中使用未记录的命令,includepaths
, 或传递 -I
运行时命令的参数 qdoc
.
我只会展示我是如何使用我的 config.qdocconf 文件让它工作的
...
# undocumented feature that simulates passing -I parameters to the command line
includepaths = . \
.. \
$QT_INSTALL_HEADERS \
$QT_INSTALL_HEADERS/QtCore \
$QT_INSTALL_HEADERS/QtGui \
$QT_INSTALL_HEADERS/QtQuick \
$QT_INSTALL_DOCS
...
您也可以使用绝对路径代替 $QT_INSTALL_HEADERS
如果需要的话。
查看这些特殊变量指向何处的简单方法是运行 qmake -query
(如果您的 qmake
命令需要,请使用您的 qt 安装 bin 的绝对路径)
编辑:对我来说,$QT_INSTALL_HEADERS
= C:/Qt/5.12.9/msvc2017_64/include
编辑 2:确保您的系统上安装了 clang(通过 chocolately、homebrew、apt 或其他),如果在 Windows 上运行 set LLVM_INSTALL_DIR=C:\Program Files\LLVM
在运行 qdoc 之前 - 此处的说明:Installing Clang for QDoc
关于c++ - 为什么 Q_OBJECT 会破坏 QDoc?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52739030/
在Qt中,我们知道Q_OBJECT是一个宏。在这种情况下,宏意味着什么?特别是我发现术语“宏”可能有几种不同的定义。 谢谢。 最佳答案 宏仅仅意味着Q_OBJECT实际上是一个C++宏。它在 src/
这个类没问题: #include class LiveImageItem : public QThread { Q_OBJECT public: LiveImageItem(QPix
我收到的错误: g++ -c -g -I/usr/lib/qt-3.3/include TCPEchoServer.cpp Product.h:22: error: ISO C++ forbids d
我在构建应用程序时收到以下链接器错误。 HIMyClass.obj:: error: unresolved external symbol "public: virtual struct QMetaO
文档指出: The Q_OBJECT macro must appear in the private section of a class definition that declares its
有个类似的问题here正在寻找解决方法和不错的指南 here它描述了 Qt 中的元对象系统。但这并没有直接解释为什么不能在元对象系统中使用模板类。这是一个令人讨厌的限制。 有人知道为什么吗? 最佳答案
有个类似的问题here正在寻找解决方法和不错的指南 here它描述了 Qt 中的元对象系统。但这并没有直接解释为什么不能在元对象系统中使用模板类。这是一个令人讨厌的限制。 有人知道为什么吗? 最佳答案
众所周知,Q_OBJECT 是实例,不可复制。 是否有任何一种语法糖可以复制任意 QObject 派生类的所有静态和动态属性? 这看起来很简单,但我找不到任何引用 - 显然自己实现一个应该很简单 -
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
当我在 Qt Creator 中创建一个新的 Q_OBJECT 类时,它会创建这个默认构造函数。我想添加另一个参数以便我可以传递用户输入,但我不确定如何执行此操作,因为 QObject 是第一个参数并
这是我的代码: 工具.h #include namespace Tinject { class ProbeCreator : public QObject {
我编写了一个扩展 QWidget 类的自定义 Qt 小部件。 让我们考虑以下代码: .h #ifndef SS_TEST_H #define SS_TEST_H #include class Tes
为什么我们通常只在私有(private)部分给出 Q_OBJECT? 我尝试了一个示例程序,在公共(public)部分给出它,我发现没有区别。 如果有人知道,你能告诉我原因吗。 最佳答案 默认情况下,
我有一个不使用 qmake 的遗留版本,但我想添加 QUdpSocket 并将其与信号和插槽连接。我有一个使用 Q_OBJECT 的类。如果我希望信号和槽可用但我没有使用 qmake,我需要做什么才能
我正在开发一个包含多个插件的 c++/Qt 程序。对于每个类,我必须定义一个如下所示的插件接口(interface): //my class class qwerty; //my interface
我有一个由 QFutureWatcher 触发的插槽。我正在尝试转换发件人以获得结果 QFutureWatcher>* QFW = qobject_cast>*>(sender()); 但不断得到 e
如何通过元编程制作基于 Q_OBJECT 的类(具有信号和/或槽的类)?我不在乎它是模板还是预处理器,两者似乎都不起作用,但我确实也需要它。 我想要的是能够将任意函数绑定(bind)到 Qt 信号。
我在一个项目中工作,其中在我需要继承的类中使用了 Q_OBJECT 宏。 已经定义了 Q_OBJECT 的类如下所示, class cBaseObject : public QObject, publ
我在 OSX Lion 中运行 QtCreator,每当我创建一个需要 Q_OBJECT 宏的类时,我都会在尝试构建我的应用程序时遇到错误。该类的代码如下,我收到的错误也是如此。有什么线索吗? 注意:
问题 自从从 Qt 5.10 升级到 Qt 5.11 后,我开始无法生成带有 QDoc 的文档。对于我现有的项目。 许多问题之一是文档中缺少函数,尽管源代码中存在相应的注释。 研究 我已设法将问题缩小
我是一名优秀的程序员,十分优秀!