Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Need a little help on Abstract lists views
Forum Updated to NodeBB v4.3 + New Features

Need a little help on Abstract lists views

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 3 Posters 536 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john_doe
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • J Offline
        J Offline
        john_doe
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • J Offline
          J Offline
          john_doe
          wrote on last edited by john_doe
          #4

          @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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved