Unsolved Need a little help on Abstract lists views
-
Hello, i'm new on qt design, i'm used to web programming as json objects and the way data is shown in qt is a little bit different.. I need a little help.
So, i'm working with a python program that needs to communicate with a qt frontend with qml, i have a basic understanding of listviews, models and delegates, what i dont understand is the abstract classes i need to work with on the backend.
I want to show a list of elements that i generate querying a database that have properties and show them on the qt UI.
For example i extract 20 fields that have for example (name: "foo", speed: "bar", lenght: "baz") on the backend and i want to wrap them on a listview and show it.
This explanation is a little bit generalist, this is something i want to do:
https://www.youtube.com/watch?v=6eHWnLyijow
But instead of showing a list from a qml listview file i want to build it from a python object/dictionary.Greets.
-
Hi and welcome to devnet,
Since you are using a database, you might want to first take a look at this wiki article about using Qt's QSqlQueryModel with QML to see if this approach covers what you need.
-
thanks for the reply, i use database queries but the data is somewhat manipulated before beign shown, i push values, and the data is manipulated before beign shown and then i show it, i would like to know if there is a way of interacting with the UI for example:
i have this data model in a list:
{
name: "foo"
width: 1000
height: 2000
bottom: 500
description: "bar baz"
}i want to pass this and show a ListModel with the name and description and put the size of the element with the width and height passed, i might need to pass svgs to beign shown, what i know is that i need to use the QAbstracListModel and create my own List Model and override the methods.
What i don't know is i have a list of this objects and i need to insert this data on my own ListModel class, and then pass it to the UI.I know on qt the delegate you can format how each element is beign shown, the list model have this format:
ListModel {
ListElement {
name: "foo"
}
ListElement {
name: "bar"
}and the list view will iterate and will show all the elements i will send from the backend.
This might seem a bad concept on how models in qt works, but that's what i understood, i just want to know how to program the abstract class and show the data on qt
-
@Denni-0 i would appreciate that, my project consists of replacing a REST API to a QT GUI, before i was using html/js on front-end, now i need to use QT.
Which means i have all the implementations methods recieving and sending json data(json is also a javascript object or a python dictionary that it's easily parsed between), now i need to translate this input/output data into QT.