关于Q_PROPERTY的问题
在网上找了下关于Q_PROPERTY的使用,如下
class Test : public QObject
{
Q_OBJECT
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
public:
Test(QObject *parent = 0) : QObject(parent) {}
virtual ~Test(){}
void setEnabled(bool e) { enabled = e; }
bool isEnabled() const { return enabled; }
private:
bool enabled;
};
然后在主函数中
Test *test = new Test;
test->setProperty("enabled", true);
//test->setEnabled(true); //ok also work
但我编译的时候总是出现下面这个错误
no matching function for call to 'Test::setProperty(cosnt char[8], bool)'
candidates are: bool QObject::setProperty(const char*, const QVariant&)
求解救啊~~~