i don’t know the problem because some tutorial of Qt using this simple method to write a dinamic string:
QML is a simple container:
Container {
id: meteoGiornaliero
preferredHeight: 75
background: Color.Blue
Label {
text: interface.interfacciaMeteoLocale("dnksandjksa") // error Expected token `;'
textStyle.color: Color.White
}
}
in my Cpp i register class like this
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
AbstractPane *root = qml->createRootObject<AbstractPane>();
// set created root object as a scene
appl->setScene(root);
cout << "Lancio Parsing"<< endl;
// QmlDocument *qmlList = QmlDocument::create("asset:///MeteoGiornaliero.qml").parent(this);
qml->setContextProperty("interface", InterfacciaDataModel::instance());
the class InterfacciaDataModel is correct because the method declarated whit macro Q_INVOKABLE
class InterfacciaDataModel: public QObject {
Q_OBJECT
public:
static InterfacciaDataModel* instance();
virtual ~InterfacciaDataModel();
MeteoLocale* mappaMeteo;
QList<MeteoLocale*> calListaInteressata(QString path);
Q_INVOKABLE QString interfacciaMeteoLocale(QString path);
private :
static InterfacciaDataModel* s_instance;
InterfacciaDataModel();
};
this error is very unusually because the error is not for sintax error, the IDE when building can’t know the Interface and can’t know if existing a problem.
i think that the problem is some import or sonting like this… anyone can help me???
↧