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. [Solved] QTableView selectionChanged event question
Forum Updated to NodeBB v4.3 + New Features

[Solved] QTableView selectionChanged event question

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.5k 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.
  • G Offline
    G Offline
    gsxruk
    wrote on last edited by
    #1

    Hi,

    I'm using a QTableView and have a function which is called when the selectionChanged event occurs. However, I'm not sure it is triggered when I'd expect (it seems a bit strange). Specifically:

    As each row is selected (I'm using row selection) the selectionChanged event is triggered, as expected.

    What I can't understand is that the event does not get triggered when, for example, the table is sorted by pressing a column header. In this case, the current row is deselected, but the selectionChanged event is not triggered.

    Am I wrong to think point 2 above should trigger the selectionChanged event? The selection has changed because nothing is now selected and it was before the sort?

    For information I'm using Qt 5.3.0.

    Thanks.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gsxruk
      wrote on last edited by
      #2

      Hi,

      Please forget this question. It's because the selection model is being reset. The documentation does state "Also note that this signal will not be emitted when the item model is reset". I'd missed that part!

      Thanks.

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

        Hi,

        Nice you found out and thanks for sharing !

        Please, update the thread title prepending [solved] so other forum users may know a solution has been found :)

        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
        0

        • Login

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