Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Modifying a ListView content from PySide
Qt 6.12 LTS is out! See what's new in the release blog

Modifying a ListView content from PySide

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 5.4k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,

    I have a problem with solving following application behavior:

    I'm working on a music player with library filters similar to iTunes or Songbird. This means I have 3 vertical lists with Genre, Artist and Album. I begin with all columns completely filled. Now when I click on genre "Rock" in first column I want the columns "Artist" and "Album" to be filled only with artists and albums from rock genre. I know how to catch the click and filter the right items from database. But I have no idea how do I change the content of the 2 ListViews.

    My backend is written in PySide. I tried to simply replace the models (QtCore.QAbstractListModel) with new ones, containing only the filtered items. But this resulted in a Python crash. What is the correct way of updating a ListView from Python? I need to keep the UI and Python data model in sync.

    I hope I explained my problem clearly.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Have you connected all you content to the category "genre".

      It also depend on the version of python and Qt.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        I already solved the problem by implementing removeRows and addItem functions of the associated QAbstractListModel following "this tutorial":http://blog.rburchell.com/2010/02/pyside-tutorial-model-view-programming_22.html.

        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
        • Unsolved