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. QListWidget: How to disable when mouse hover ,the items change background color?
QtWS25 Last Chance

QListWidget: How to disable when mouse hover ,the items change background color?

Scheduled Pinned Locked Moved Solved General and Desktop
qlistwidgethover
8 Posts 4 Posters 10.7k 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.
  • brucezcgB Offline
    brucezcgB Offline
    brucezcg
    wrote on last edited by
    #1

    For QListWidget
    By Default when mouse hover ,the list items will change background color.
    How to disable this feature?
    I want the item do nothing when mouse hover the list items.

    Thanks

    A 1 Reply Last reply
    0
    • brucezcgB brucezcg

      For QListWidget
      By Default when mouse hover ,the list items will change background color.
      How to disable this feature?
      I want the item do nothing when mouse hover the list items.

      Thanks

      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      @brucezcg Here's 2 different ways to do it.. One with CSS (the easy way) and the other with a custom paint (the hard way).

      https://stackoverflow.com/questions/16016644/deactivated-qlistwidgetitem-hover

      https://stackoverflow.com/questions/42403175/qlistwidget-disable-mouseover-highlight

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

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

        Hi,

        Two solutions comes to mind:

        • QStyledItemDelegate
        • Qt Style Sheet

        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
        2
        • brucezcgB Offline
          brucezcgB Offline
          brucezcg
          wrote on last edited by
          #4

          I don't want to change background color when hover,
          I just want to disable hover, when hover, the items stay the background color, may be different colors, so I couldn't set
          hover to certain color.

          D A 2 Replies Last reply
          0
          • brucezcgB brucezcg

            I don't want to change background color when hover,
            I just want to disable hover, when hover, the items stay the background color, may be different colors, so I couldn't set
            hover to certain color.

            D Offline
            D Offline
            Devopia53
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then QStyledItemDelegate it is.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              brucezcgB 1 Reply Last reply
              0
              • SGaistS SGaist

                Then QStyledItemDelegate it is.

                brucezcgB Offline
                brucezcgB Offline
                brucezcg
                wrote on last edited by
                #7

                @ambershark @SGaist Get it, Thanks.

                1 Reply Last reply
                0
                • brucezcgB brucezcg

                  I don't want to change background color when hover,
                  I just want to disable hover, when hover, the items stay the background color, may be different colors, so I couldn't set
                  hover to certain color.

                  A Offline
                  A Offline
                  ambershark
                  wrote on last edited by
                  #8

                  @brucezcg said in QListWidget: How to disable when mouse hover ,the items change background color?:

                  I don't want to change background color when hover,
                  I just want to disable hover, when hover, the items stay the background color, may be different colors, so I couldn't set
                  hover to certain color.

                  Well in that post I linked you on stackoverflow, it shows:

                  QListWidget::item:hover,
                  QListWidget::item:disabled:hover,
                  QListWidget::item:hover:!active,
                  {background: transparent;}
                  

                  That means it just hides the hover, doesn't set it to a certain color. It should do exactly what you need.

                  You can of course make a custom delegate too. That's more work that setting a quick css though.

                  My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                  1 Reply Last reply
                  1

                  • Login

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