[SailfishDevel] QML C++ Integration not working in Sailfish

antonio.cano.gomez at ovi.com antonio.cano.gomez at ovi.com
Thu Feb 27 12:38:53 UTC 2014


Yes, it helped thanks.

My problem now is different.

I have some private attributes in my C++ object.

When I call the first tiem I can modify the attributes, but in the second call the attributes dessapear.

Is there a way to solve this problem?

(The attributes a new C++ Object not declared as QObject)





El Jueves 27 de febrero de 2014 12:32, Stefan Brand <stefan.brand at seiichiro0185.org> escribió:
 
Hi,
>
>On 25.02.2014 15:06, antonio.cano.gomez at ovi.com wrote:
>> An I try to connect this with my sailfish application with the code:
>> 
>>  QGuiApplication *app = SailfishApp::application(argc, argv);
>>  QQuickView *view = SailfishApp::createView();
>>  Bloomfilters * bloomfilters = new Bloomfilters();
>>  view->rootContext()->setContextProperty("Bloomfilters",
>> bloomfilters);
>>  view->setSource(SailfishApp::pathTo("qml/bloomfilter.qml"));
>>  view->showFullScreen();
>>  return app->exec();
>> 
>> But this is not working.
>> 
>> Someone have any idea about what am I doing wrong?
>> 
>
>You can use qmlRegisterType to pass the Info of the C++ class to QML 
>like this in the cpp:
>
>#include "bloomfilters.h"
>
>int main(int argc, char *argv[])
>{
>   // Get App and QML-View objects
>   QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, 
>argv));
>   QScopedPointer<QQuickView> view(SailfishApp::createView());
>
>   // Register Bloomfilter Class
>   qmlRegisterType<Bloomfilter, 1>("harbour.myapp.Bloomfilter", 1, 0, 
>"Bloomfilter");
>
>   // Prepare the QML
>   view->setSource(SailfishApp::pathTo("qml/bloomfilter.qml"));
>   view->show();
>
>   // Run the app
>   return app->exec();
>}
>
>Afterwards you can create a Bloomfilter-Object in QML:
>
>Bloomfilter {
>   id: bloom
>}
>
>and use the methods with
>
>bloom.insertElement("myelement")
>
>I hope this helps.
>
>
>Regards
>
>Stefan Brand
>_______________________________________________
>SailfishOS.org Devel mailing list
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20140227/74e14b8a/attachment.html>


More information about the Devel mailing list