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

拟墨画扇 提交于 2019-12-12 05:49:54

问题


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:


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.



来源:https://stackoverflow.com/questions/14109774/void-value-not-ignored-as-it-ought-to-be-qt-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!