Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QTreeView Item highlight problem

    General and Desktop
    1
    4
    2499
    Loading More Posts
    • 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
      ddolby last edited by

      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 Reply Quote 0
      • D
        ddolby last edited by

        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 Reply Quote 0
        • D
          ddolby last edited by

          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 Reply Quote 0
          • D
            ddolby last edited by

            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 Reply Quote 0
            • First post
              Last post