[SailfishDevel] Problem in interaction qml and c++

David Llewellyn-Jones david at flypig.co.uk
Thu Apr 23 06:59:19 UTC 2020


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.

David
-- 
Website: https://www.flypig.co.uk


More information about the Devel mailing list