Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to observe changes in a list
Forum Updated to NodeBB v4.3 + New Features

How to observe changes in a list

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 350 Views
  • 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.
  • LeonaderL Offline
    LeonaderL Offline
    Leonader
    wrote on last edited by
    #1

    Greetings fellow devs. I'm new to C++ and Qt, and I'm currently working on an app that plays music, which uses the Phonon media API. This app is meant to have a queue of music tracks which are meant to play in order. Tracks can be added and removed to and from that list at any time. The app is also meant to have an area which always displays an up-to-date image of that queue. What I'm struggling with is how to update said area each time the queue changes. The class Phonon::MediaObject that hosts the queue doesn't seem to have any signal which would help me detect changes in the queue at all. Even the type of the queue, QList, doesn't seem to cast a signal when changed. This doesn't seem to leave me any options within the MediaObject class, so I'm now a bit lost.. My next attempt would be to implement a new class which inherits MediaObject, but this would come with a lot of new challenges which I think I would be wise to avoid. Could any of you perhaps tell me how to do this? Or is there another solution that I'm missing? I'd be very thankful for a bit of help.
    Documentation for the MediaObject class can be found here: https://api.kde.org/phonon/html/classPhonon_1_1MediaObject.html
    The code for MediaObject can be found here: https://invent.kde.org/libraries/phonon/-/blob/master/phonon/mediaobject.cpp

    jsulmJ 1 Reply Last reply
    0
    • LeonaderL Leonader

      Greetings fellow devs. I'm new to C++ and Qt, and I'm currently working on an app that plays music, which uses the Phonon media API. This app is meant to have a queue of music tracks which are meant to play in order. Tracks can be added and removed to and from that list at any time. The app is also meant to have an area which always displays an up-to-date image of that queue. What I'm struggling with is how to update said area each time the queue changes. The class Phonon::MediaObject that hosts the queue doesn't seem to have any signal which would help me detect changes in the queue at all. Even the type of the queue, QList, doesn't seem to cast a signal when changed. This doesn't seem to leave me any options within the MediaObject class, so I'm now a bit lost.. My next attempt would be to implement a new class which inherits MediaObject, but this would come with a lot of new challenges which I think I would be wise to avoid. Could any of you perhaps tell me how to do this? Or is there another solution that I'm missing? I'd be very thankful for a bit of help.
      Documentation for the MediaObject class can be found here: https://api.kde.org/phonon/html/classPhonon_1_1MediaObject.html
      The code for MediaObject can be found here: https://invent.kde.org/libraries/phonon/-/blob/master/phonon/mediaobject.cpp

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Leonader said in How to observe changes in a list:

      My next attempt would be to implement a new class which inherits MediaObject

      Why do you want to subclass MediaObject? It is the list of MediaObject which needs to emit a signal if it changes, right? One way would be to implement a class containing QList<MediaObject*> with a well defined interface to alter the list and also all needed signals (like changed()).
      Depending on how you're showing this list you should consider using https://doc.qt.io/qt-6/model-view-programming.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      LeonaderL 1 Reply Last reply
      2
      • jsulmJ jsulm

        @Leonader said in How to observe changes in a list:

        My next attempt would be to implement a new class which inherits MediaObject

        Why do you want to subclass MediaObject? It is the list of MediaObject which needs to emit a signal if it changes, right? One way would be to implement a class containing QList<MediaObject*> with a well defined interface to alter the list and also all needed signals (like changed()).
        Depending on how you're showing this list you should consider using https://doc.qt.io/qt-6/model-view-programming.html

        LeonaderL Offline
        LeonaderL Offline
        Leonader
        wrote on last edited by
        #3

        @jsulm No, it is not a list of MediaObjects, it is a property of MediaObject, which is a list of MeiaOutputs (another class in that namespace). My idea was to subclass MediaObject so I can try to implement this signal into it.

        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