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. QTreeView Item highlight problem

QTreeView Item highlight problem

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 2.8k 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.
  • D Offline
    D Offline
    ddolby
    wrote on last edited by
    #1

    All,

    I have implemented a class that inherits from QTreeView. I am having a problem where occasionally if I CTRL+Click some items, and then click within the Tree widget, but not on an item, or I click an item without CTRL+Click I one of the originally selected items remains highlighted, but not the clicked highlighted, more like the mouse hover highlighted.

    I have overwritten the following routines

    void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected )
    void mousePressEvent ( QMouseEvent * event )

    Both of these overwritten routines delegate to the QTreeView parent, but then check what is selected in order to emit certain signals to enable/disable buttons on the UI.

    What is the signal or event or state that gives the item the highlighted look?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      ddolby
      wrote on last edited by
      #2

      As I test this more it looks like I can get the strange highlighting only if I move the mouse while the button is pressed.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        ddolby
        wrote on last edited by
        #3

        I have stepped into the qtreeview.cpp code and it looks like for some reason the QTreeViewPrivate object thinks that this index is still assigned to the "hover" object within the tree. Does anyone know how I can clear the "hover" member of the QTreeViewPrivate object?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          ddolby
          wrote on last edited by
          #4

          This is probably not the best solution to this problem, but in my overwritten mousePressEvent I am calling the QTreeView::mouseMoveEvent which causes the hover object to be cleared out. This has resolved my problem, but it feels like too much of a hack, so I would appriciate anyone's feedback.

          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