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. How to remove QPushButton border but keep effect
QtWS25 Last Chance

How to remove QPushButton border but keep effect

Scheduled Pinned Locked Moved Unsolved General and Desktop
qpushbuttonstylesheetqicon
3 Posts 2 Posters 2.8k 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.
  • D Offline
    D Offline
    dporobic
    wrote on 31 Mar 2021, 19:41 last edited by
    #1

    I'm trying to recreate the Float and Close button from the QDockWidget default title bar, they look like this:
    979fe779-45c0-4fd8-868e-bbc2f2c0b84e-image.png

    I have figured out so far how to get that icon and as far:

    auto icon = style()->standardIcon(QStyle::SP_TitleBarNormalButton, nullptr, this);
    

    As I can see the icon has the three states that I require, normal, hover and pressed. Added to a QPushButton it looks as expected. Now I have removed the border by changing the StyleSheet:

    button->setStyleSheet("QPushButton {border-style: outset; border-width: 0px;}");
    

    The button looks now exactly as I need it to look but the problem is that there is no hover effect and if I click on the button it changes the icon to the pressed state as expected but when I release it, it stays in that state. Interesting is that when I click on the that same button of another dock widget, the first button goes back to normal state and the second button stays in the pressed state. Any idea what might be going wrong or what an alternative could be?

    https://github.com/ksnip/ksnip

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 1 Apr 2021, 10:32 last edited by
      #2

      Hi
      When you apply a stylesheet, the normal drawing is no longer in effect.
      So you have to style it fully.
      For hover, you might want to use ":hover" key to assign an effect.

      For the stay down, Im a bit baffled.
      It really sounds like it's flagged as checkable and shares a button group with the other instances.
      But Not sure where that would come from.
      You set a custom widget to title bar ?

      1 Reply Last reply
      1
      • D Offline
        D Offline
        dporobic
        wrote on 11 Apr 2021, 08:32 last edited by
        #3

        Yes, it was a custom widget in title bar. I wasn't able to figure out where this is coming from so I went with a different solution but still strange behavior.

        https://github.com/ksnip/ksnip

        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