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. Disable sinking of QToolButton when pressed
Qt 6.11 is out! See what's new in the release blog

Disable sinking of QToolButton when pressed

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 4.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.
  • A Offline
    A Offline
    A1exander_Z
    wrote on last edited by
    #1

    Is it possible to disable visual "sinking" effect of QToolButton when it is pressed? I have some customized buttons with visual feedback provided by icon change, and the additional shift of the icon by 1 pixel right and 1 pixel down is unnecessary and annoying.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Well you always can customize QToolButton with "qss":http://qt-project.org/doc/qt-5/stylesheet-examples.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        A1exander_Z
        wrote on last edited by
        #3

        The buttons are already customized with CSS (for example, they have custom borders), but I have no idea how to disable sinking with CSS. Changing border for QToolButton:pressed does not help.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          Can you tell me what OS and Theme you have, so i can test it?
          And show screen shot of sinking QToolButton if possible.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            A1exander_Z
            wrote on last edited by
            #5

            Windows 7 64-bit Ultimate, Qt 5.2.1, MinGW 32-bit compiler, default theme (I do not use any custom themes). Here is a simple CSS (applied for the entire application) I use for testing:

            @QToolButton {
            border: 1px solid blue;
            }

            QToolButton:pressed {
            border: 1px solid red;
            }@

            The 'border' property works, the button looks as a colored rectangle with an icon inside, nothing else. I can see border color changing when the button is pressed, but there is also a visible move of the button icon right and down. The icon is set by the QToolButton::setIcon method in the code and (in the test case) is the same for all button states.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              A1exander_Z
              wrote on last edited by
              #6

              I have found "this thread":http://qt-project.org/forums/viewthread/15517 and tried to use QProxyStyle, but without success. I have created a subclass of QProxyStyle, FlatToolButtonProxyStyle, as suggested, and applied it to my tool button:

              @ui->toolButton->setStyle(new FlatToolButtonProxyStyle);@

              It does nothing. Moreover, when I run the application under debugger, pixelMetric method of FlatToolButtonProxyStyle is never called.

              1 Reply Last reply
              0
              • Marco FeuersteinM Offline
                Marco FeuersteinM Offline
                Marco Feuerstein
                wrote on last edited by
                #7

                The same just happened to me. pixelMetric simply wasn't called because I forgot to declare it const.

                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