Am 23.04.2020 08:59 schrieb David Llewellyn-Jones:
On 23/04/2020 09:51, Michael Fuchs wrote:
How can AlbumList access mImgDB and mNetAccess?

One solution could be to register the controller itself in qml and then write
sth like this in qml:

====
AlbumList {
  imgDB: controller.imgDB
  netAccess: controller.netAccess
}
====

but it's redundant.

This doesn't look like a bad approach to me (although passing the
controller itself might be cleaner).

An alternative might be to make Controller a singleton, that way your
AlbumList class could access it from the C++ without needing to be
explicitly passed a handle to it.

But whether you can do that depends on the how Controller is used.


Thanks a lot.
I'm not familiar with singletons, but this sounds promising.
I found this simple example:

https://gist.github.com/pazdera/1098119

I hope this also works for Q_OBJECT s.
Maybe I should rather make netAccess and imgDB itself singletons?

fooxl


_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Reply via email to