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. Custom PushButton
Qt 6.11 is out! See what's new in the release blog

Custom PushButton

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.7k 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
    GrahamL
    wrote on last edited by
    #1

    Hi
    How can I stop the appearance of a QPushButton changing when it is hovered over or pressed.
    I know how to change the background colour for these events by setting the appropriate stylesheet, but cannot see how I can stop them changing at all.
    I would appreciate some help in getting this working

    Thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maximus
      wrote on last edited by
      #2

      Hi,

      Try with the :event syntax

      Example :
      QPushButton:hover { color: white }

      Good luck!


      Free Indoor Cycling Software - https://maximumtrainer.com

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        [quote author="GrahamL" date="1385052636"]
        I know how to change the background colour for these events by setting the appropriate stylesheet, but cannot see how I can stop them changing at all.[/quote]
        You mean that a hovered button looks exactly the same like a non-hovered button?
        If thats the case you can do this:
        @
        void MyPushButton::paintEvent(QPaintEvent *)
        {
        QStylePainter p(this);
        QStyleOptionButton option;
        initStyleOption(&option);
        option.state &= ~QStyle::State_MouseOver; //remove hover flag in all cases ("~" is supposed to be a tilde-sign)
        p.drawControl(QStyle::CE_PushButton, option);
        }
        @

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        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