我有一个由QFutureWatcher触发的插槽。我正在试图让发送者获得结果
QFutureWatcher<QPair<QImage,QString>>* QFW = qobject_cast<QFutureWatcher<QPair<QImage,QString>>*>(sender());
但继续得到
error: static assertion failed: qobject_cast requires the type to have a Q_OBJECT macro
我不确定这里有什么问题,这些都是Qt内置类型,所以我做错了什么?
你必须将Q_OBJECT放在类定义中,如下所示:
class MyClass : public QObject
{
Q_OBJECT
// ^^^^^^^^^^
public:
MyClass();
/*...*/
}