我有一个界面MyInterface
:
class MyInterface
{
public:
virtual ~MyInterface() {}
virtual QMap<QString, QString> *inputsMap() const = 0;
};
我有一个实现MyInterface
的 MyImplementingClass 类。但是,我无法从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**
的文本输入?
提前谢谢大家。