“空值不应被忽略,因为它应该是” - Qt / C ++ [英] "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:
但是当构建它时,我得到 void value not忽略,因为它应该是
和Qt creator说实例化从行我做我的演员...不能弄清楚我做错了什么...任何帮助/ c> TestPluginBase(){this-> TestPluginBase(){
qint64 TestPluginManager::loadPlugin(QObject *_plugin)
{
TestPluginBase *Plugin = qobject_cast<TestPluginBase *>(_plugin);
if ( !Plugin )
return 0;
emit sigPluginLoaded(Plugin);
return Plugin->returnType();
}
推荐答案
> PluginType = 0;} ,代码正在编译没有错误。解决我的问题,但不知道为什么。
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.
这篇关于“空值不应被忽略,因为它应该是” - Qt / C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!