Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTableView item update: when underlying model is effectively updated ?
Qt 6.12 LTS is out! See what's new in the release blog

QTableView item update: when underlying model is effectively updated ?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 618 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.
  • A Offline
    A Offline
    Andrea_Benetton
    wrote on last edited by Andrea_Benetton
    #1

    I see that in my application (Windows as OS, QT 5.15) the QStandardItemModel :: dataChanged event is raised only if I complete the cell editing with a "return" or by clicking with the mouse on another cell of the QTableView. If I go directly to the menu of my application, the QAction method is executed first and then the method connected to the dataChanged is called. Is it possible to modify this behavior by setting a property of the QTableView or by forcing the cell's updated status in the method called by the QAction?

    JonBJ 1 Reply Last reply
    0
    • A Andrea_Benetton

      I see that in my application (Windows as OS, QT 5.15) the QStandardItemModel :: dataChanged event is raised only if I complete the cell editing with a "return" or by clicking with the mouse on another cell of the QTableView. If I go directly to the menu of my application, the QAction method is executed first and then the method connected to the dataChanged is called. Is it possible to modify this behavior by setting a property of the QTableView or by forcing the cell's updated status in the method called by the QAction?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Andrea_Benetton said in QTableView item update: when underlying model is effectively updated ?:

      If I go directly to the menu of my application, the QAction method is executed first and then the method connected to the dataChanged is called

      I guess this is possible, but slightly surprised, though I take your word.

      So you just want the dataChanged signal, which comes at the end of editing, to be sent before the QAction::triggerred signal. right?

      Then I wouldn't do any fancy code. You just want to swap the order of these signals, then your code will work. There are several ways of doing this. Simplest, I think, would be to make the triggered menu action be connect()ed with a Qt::QueuedConnection. Then the slot won't be called till the event loop is hit, and presumably the dataChanged, connect()ed with Qt::DirectConnection, will have gone through first. That's what I would try, one line code change to see where you are.

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Andrea_Benetton
        wrote on last edited by
        #3

        Thank you @JonB .
        It was not a signal issue. It was the focusPolicy property of QMenuBar that the QtDesigner set by default to "NoFocus". Changing it to "ClickFocus" set the behavior correctly for my case.

        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