Note that there are some explanatory texts on larger screens.

plurals
  1. POQML - Q_INVOKABLE functions
    primarykey
    data
    text
    <p>I have a problem with QML, with calling Q_INVOKABLE functions. Although I marked functions as Q_INVOKABLE I'm getting errors</p> <pre><code>TypeError: Result of expression 'azdownloader.setData' is not a function TypeError: Result of expression 'azdownloader.perform' is not a function </code></pre> <p>I have this class:</p> <pre><code>typedef QString lyricsDownloaderString; class lyricsDownloader : public QObject { public: Q_INVOKABLE virtual short perform() = 0; Q_INVOKABLE inline void setData(const string &amp; a, const string &amp; t); // set artist and track // some other data protected: lyricsDownloader(const string &amp; a, const string &amp; t ) : artist(a), track(t) {} /*other data*/ }; class AZLyricsDownloader : public lyricsDownloader { public: AZLyricsDownloader() : lyricsDownloader("", "") {} AZLyricsDownloader(const string &amp; a, const string &amp; t) : lyricsDownloader(a, t) {} Q_INVOKABLE short perform(); Q_INVOKABLE inline void setData(const string &amp; a, const string &amp; t);// set artist and track /*other data*/ </code></pre> <p>In main.cpp</p> <pre><code>Q_DECL_EXPORT int main(int argc, char *argv[]) { QApplication app(argc, argv); mainWindow viewer; qmlRegisterUncreatableType&lt;lyricsDownloader&gt;("MaeLyrica", 1, 0, "lyricsDownloader", ""); qmlRegisterType&lt;AZLyricsDownloader&gt;("MaeLyrica", 1, 0, "AZLyricsDownloader"); viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String("qml/maelyrica/main.qml")); viewer.showFullScreen(); return app.exec(); } </code></pre> <p>in main.qml</p> <pre><code>import QtQuick 1.1 import com.nokia.meego 1.0 import com.nokia.extras 1.0 import MaeLyrica 1.0 //property color fontcolor: "white" PageStackWindow { id: pagestackwindow visible: true MainPage { id: mainview } initialPage: mainview AZLyricsDownloader { id: azdownloader } } </code></pre> <p>And in the pages</p> <pre><code>import QtQuick 1.1 import com.nokia.meego 1.0 Page { /*some gui elements*/ Button { id: go text: "Go!" width: parent.width onClicked: { goLoader.source = "ShowLyricsPage.qml" pageStack.push(goLoader.item) azdownloader.perform() showLyricsPage.busyind.visible = false } } } /*dialogs and toolbar definitions*/ } </code></pre> <p>The other one:</p> <pre><code>import QtQuick 1.1 import com.nokia.meego 1.0 Sheet { id: sheet acceptButtonText: "Save" rejectButtonText: "Cancel" onAccepted: { if ( artistfield.text == "" || trackfield.text == "" ) // check whether empty { emptyfieldsdialog.open() } else { selecttrack.text = artistfield.text + " - " + trackfield.text azdownloader.setData(artistfield.text, trackfield.text) } } content: Rectangle { /*some content here*/ } /*dialog definition*/ </code></pre> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload