Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. qtreeview select single item & column
Forum Updated to NodeBB v4.3 + New Features

qtreeview select single item & column

Scheduled Pinned Locked Moved Solved Language Bindings
3 Posts 2 Posters 3.4k Views 2 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.
  • H Offline
    H Offline
    hermes
    wrote on last edited by
    #1

    I wonder if someone could help me with the following issue:

    • I have a qtreeview and a QAbstractItemModel. with multiple columns (using pyqt5)
    • When I select a certain column of one index (one "field"), the whole row turns blue and he field additionally gets a thin white line at the bottom.
    • When I access the currentindex.column() function I always get the first column "0" (only if I go and edit a certain column the correct colum-id is available in my setdata function).

    -> I'd like to change the behavior such that really only one "field" (one column of one item) is highlighted or - if this is not possible "at east" get the correct column-id

    I could not find a suitable option in the selectionmodel or selectionmode... There seems to be only options about multi-selection etc. Did I miss something....?

    Thanks a lot in advance!

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

      Hi,

      From what you wrote, QAbstractItemView::SingleSelection and QAbstractItemView::SelectItems comes to mind.

      Hope it helps

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

        Thanks a lot for the hints!

        I had tried these without success but your input triggered me to look further in this direction and I discovered something called selectionbehavior.

        In pyqt5 I use:
        self.view.setSelectionBehavior(QAbstractItemView.SelectItems)

        Thanks again!

        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