简体   繁体   中英

“void value not ignored as it ought to be” - Qt/C++

I have this simple "interface" for some plugins I want to develop, it looks like:

class TestPluginBase : public QObject
{
  Q_OBJECT
public:
    TestPluginBase();
    qint64 returnType(){return PluginType;}

protected:
    qint64 PluginType;
};

And some other classes which implement the "interface" like:

class TestPluginONE : public TestPluginBase
{
public:
    TestPluginONE() {this->PluginType =1;}
    qint64 returnType() {return this->PluginType;}
};

Then I have another function which suppose to load different plugins:

qint64 TestPluginManager::loadPlugin(QObject *_plugin)
{

  TestPluginBase *Plugin = qobject_cast<TestPluginBase *>(_plugin);

  if ( !Plugin )
        return 0;

    emit sigPluginLoaded(Plugin);
    return Plugin->returnType();

}

But when building it I get void value not ignored as it ought to be and Qt creator says instantiated from the line I'm doing my cast... can't figure out what I'm doing wrong...any help/hint is appreciated.

在“接口”中将构造函数修改为TestPluginBase() {this->PluginType =0;} ,并且代码正在编译,没有错误..解决了我的问题,但不知道为什么。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM