我有一个界面MyInterface
:
class MyInterface
{
public:
virtual ~MyInterface() {}
virtual QMap<QString, QString> *inputsMap() const = 0;
};
我有一个类MyImplementingClass实现MyInterface
. 但是,我无法从以下位置获取文本QLineEdit *fullNames
:
QLineEdit *fullNames = new QLineEdit();
QMap<QString, QString> *MyImplementingClass::inputsMap() const
{
QMap<QString, QString> *map = new QMap<QString, QString>();
map -> insert("fullNames", this -> fullNames -> text());
map -> insert("coolText", "This works OK");
return map;
}
在ImplementorsCollector
是我收集所有实现插件的地方MyInterface
:
void ImplementorsCollector :: initImplementors(QObject *plugin)
{
MyInterface *iMyInterface = qobject_cast<MyInterface *>(plugin);
if (iMyInterface)
myObject = iMyInterface -> inputsMap();
}
但是,仍然在ImplementorsCollector
:
/* This prints nothing. Nothing gets passed from **QLineEdit *fullNames** */
if (myObject -> contains("fullNames"))
qDebug() << "fullNames : " << myObject -> value("fullNames");
/* This prints OK */
if (myObject -> contains("coolText"))
qDebug() << "coolText : " << myObject -> value("coolText");
如何**QLineEdit *fullNames**
从不同的插件获取文本输入?
谢谢大家。