我想知道是否可以(以及如何)使用 C++ 运算符,例如 ()、[] 作为 Qt 插槽。
编译器似乎在抱怨这个简单的代码
class MainWindowDecorator : public QObject
{ Q_OBJECT
private:
//some variables
public slots:
int operator[](int i)
{
return i;
}
}
错误如下:
Error: Not a signal or slot declaration
您可以创建调用专用
operator
的插槽包装器。
问题在于
moc
解析器不允许该定义,可能是因为它需要标识符而不是关键字。