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

2019-09-06 15:33发布

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.

1条回答
劳资没心,怎么记你
2楼-- · 2019-09-06 16:05

modified the constructor in my "interface" to TestPluginBase() {this->PluginType =0;} and the code is compiling with no error..solved my problem but don't know why.

查看更多
登录 后发表回答