Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

QML thumbnail list

$
0
0
Hi all, I have a problem making a thumbnail list/view in QML – I have no idea where to start with this. I’ve been searching a lot through Qt documentation and stackoverflow, but even though there are some “solutions”, they are either not working for my system or not flexible enough. So, the end-effect should be an app similar to Android gallery – once Gallery is loaded, all the images are refreshed. User should also be able to delete images and so on. I should point out that there is quite some C++ code in the underlying Qt app, and QML frontend is only constructed via QQmlApplicationEngine engine(QUrl("qrc:///camera_app.qml")); in main.cpp. I’ve created a GridView and statically assigned some images to it and it looks good. The static allocation looks like this: ListModel {         id: imageModel         ListElement {             name: "Image 01"             imageUrl: "file:///home/DCIM/image_0000.jpeg"         }         ListElement {             name: "Image 02"             imageUrl: "file:///home/DCIM/image_0001.jpeg"         }         ListElement {             name: "Image 03"             imageUrl: "file:///home/DCIM/image_0002.jpeg"         }         ListElement {             name: "Image 04"             imageUrl: "file:///home/DCIM/image_0003.jpeg"         } } However, I’m yet to find a way to dynamically add/remove pictures to/from imageModel. I have tried several ways including trying to do it from C++ with setContextProperty(), but they’re not flexible enough, since this requires a pointer to the quickview, which is only available in my main.cpp, not in my underlying c++ code… Not to mention that it doesn’t really work, since my ListModel is not in the main QML file. There is also a way to expose C++ model to the QML, but this exposes only model structure, not the list, so I can’t really use it (or don’t know how to). I would really appreciate some help here, as this is the only thing that’s been blocking me. In contrast I thought that this would be an easy part… So basically any guidance/advice for some sort of gallery would do just fine. Thanks!

Viewing all articles
Browse latest Browse all 4972

Trending Articles