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. Persistens selection in Tableview
QtWS25 Last Chance

Persistens selection in Tableview

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.2k 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.
  • M Offline
    M Offline
    Maser
    wrote on last edited by Maser
    #1

    Hi.
    I wanted to ask to for a general suggestion.
    I have a tablemodel, containing a set of constant data. I use a delegate to represent this data in a tableview in a way that to that data to each cell is addet a countdown, showing how much is left, and a progressbar.
    Currently i use

     void emitFakeResetModelSignal()
    { 
    beginResetModel(); 
    endResetModel(); 
    };
    

    connected to a timer to fake that data is changed, so the countdowns are updatet every second, although the data itself isnt changed, i just calculate additional information "on demand", which is adressed by tablemodels data() function. I hope i explained it understandable)))
    Now i want to be able to select rows in tableview and then delete or modify the selected entrys in my model. But since the view updates every second the selection holds only for a second. What is a good approach to make a persistens selection here?

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

      Hi,

      Rather that triggering a model reset, why not just emit dataChanged for the index in questions ?

      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
      • M Offline
        M Offline
        Maser
        wrote on last edited by
        #3

        I need the view to be constantly uptodate. So all the cells have to be updated every second or so.

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

          Then emit dataChanged for the whole table.

          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
          • M Offline
            M Offline
            Maser
            wrote on last edited by Maser
            #5

            Great, thanks))

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Maser
              wrote on last edited by Maser
              #6

              I have to reopen the thread, couse the problem is on the same subject.
              I have now addet some delegates to my table. I use QCombobox to allow some values to be changed when i want to edit a cell. Problem is, when i open the editor, the table keeps updating every second and each update the combobox gets additional items. Say i offer 3 entry to chose from, ent1, ent2, ent3. So when i keep editor open every second its becomes ent1, ent2, ent3, ent1, ent2, ent3, .... and so on. Do you have some suggestion?

              I solved it now with checking

              if(pQComboBox->count() == 0){//fill combobox}
              

              every time setEditorData is called, but i stil wonder why this happens at all.

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by VRonin
                #7

                in the delegate you could call blockSignals(true) in the first line of createEditor() and blockSignals(false) in the first line of editorEvent()

                I don't like it tbh but nor do I like changing the entire model every second for that matter

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of 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