问题
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