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/Widget selection highlight
Forum Updated to NodeBB v4.3 + New Features

QTreeView/Widget selection highlight

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.9k 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
    greg.hellings
    wrote on last edited by
    #1

    A simple Google Search easily turns up how to remove the dotted/dashed rectangle around tree items. I have a more sinister question - how can I remove the blue background highlight for the currently selected item? I'm attempting to use a tree widget paired with a stack to simulate tabs with a tree structure. Everything works great, but visually that blasted blue background is still there for the currently selected item and I haven't yet been able to remove it.

    Source code for my combined widget lives here https://github.com/greg-hellings/qtreetabs-qt5 - any assistance or advice on how I might get rid of that blue background would be appreciated.

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

      Hi and welcome to devnet,

      Should your item be selectable ?

      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
      • G Offline
        G Offline
        greg.hellings
        wrote on last edited by
        #3

        Thanks!

        Yes, they should be selectable. The tree represents the vertical depiction of the TabBar. I'm indicating the currently selected/active tab by use of other styling mechanisms. These primarily involve shading the rest of the background, modifying the border, etc to mimic a normal tab structure. However, that blue bar keeps hanging around. Here's the picture of what I currently have - it's the blue on the left, which is the background bleeding through, which I want to get rid of:

        http://pictures.thehellings.com/screenies/bluebackground.png

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

          Then you can use a QStyledItemDelegate where you ensure that the painting options doesn't contain QStyle::State_Selected

          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
          • G Offline
            G Offline
            greg.hellings
            wrote on last edited by
            #5

            I have been down this path a little ways before, though I didn't know very much of what I was doing back then. Tried it again now that I know very slightly more. Amusingly, this had the opposite effect of what I wanted - it cleared out my custom stylesheet based on the :selected pseduoclass but left the blue background in place.

            http://pictures.thehellings.com/screenies/styledoverride.png

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

              Can you show your code ?

              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