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?

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.
  • B Offline
    B Offline
    brucezcg
    wrote on 12 Mar 2018, 08:43 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 12 Mar 2018, 22:44
    0
    • B brucezcg
      12 Mar 2018, 08:43

      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 12 Mar 2018, 22:44 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
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 12 Mar 2018, 22:46 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
        • B Offline
          B Offline
          brucezcg
          wrote on 13 Mar 2018, 09:49 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 13 Mar 2018, 11:03
          0
          • B brucezcg
            13 Mar 2018, 09:49

            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 13 Mar 2018, 11:03 last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 13 Mar 2018, 11:09 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

              B 1 Reply Last reply 14 Mar 2018, 00:58
              0
              • S SGaist
                13 Mar 2018, 11:09

                Then QStyledItemDelegate it is.

                B Offline
                B Offline
                brucezcg
                wrote on 14 Mar 2018, 00:58 last edited by
                #7

                @ambershark @SGaist Get it, Thanks.

                1 Reply Last reply
                0
                • B brucezcg
                  13 Mar 2018, 09:49

                  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 14 Mar 2018, 02:38 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

                  8/8

                  14 Mar 2018, 02:38

                  • Login

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