Important: Please read the Qt Code of Conduct -

[SOLVED] BlackBerry 10 - Error QML " Expected token `;’ "

  • 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
    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 {
    static InterfacciaDataModel* instance();
    virtual ~InterfacciaDataModel();
    MeteoLocale* mappaMeteo;
    QList<MeteoLocale*> calListaInteressata(QString path);

    Q_INVOKABLE QString interfacciaMeteoLocale(QString path);

    private :
    static InterfacciaDataModel* s_instance;

    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???

  • Solved whit this:
    qml->setContextProperty("Interface", InterfacciaDataModel::instance()); @

    and then i have use First caps letter!!

  • I've had errors like those when something is not right in any header file included.

    Hope it helps you.

Log in to reply