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. QToolButton Style

QToolButton Style

Scheduled Pinned Locked Moved Solved General and Desktop
qtoolbuttonstyesheet
11 Posts 4 Posters 2.0k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 5 Jul 2021, 18:50 last edited by
    #2

    Hi,

    Out of curiosity, what is the issue with the fact that the button sinks ?
    Removing the animation would make the use of your toolbar a bit awkward with regard to the usual GUI guidelines.

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

    S 1 Reply Last reply 6 Jul 2021, 14:55
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on 6 Jul 2021, 00:15 last edited by ChrisW67 7 Jun 2021, 00:17
      #3

      Like QPushButton::setFlat() only for QToolButton? QToolButton does not seem to have an equivalent.

      S 1 Reply Last reply 6 Jul 2021, 15:21
      0
      • S SGaist
        5 Jul 2021, 18:50

        Hi,

        Out of curiosity, what is the issue with the fact that the button sinks ?
        Removing the animation would make the use of your toolbar a bit awkward with regard to the usual GUI guidelines.

        S Offline
        S Offline
        Saviz
        wrote on 6 Jul 2021, 14:55 last edited by
        #4

        @SGaist

        I want to use QToolButton istead of QPushButton for my usual buttons.
        (I do this because it has more options for text beside icons)
        Due to this reason I want to stop it from doing the animation.

        1 Reply Last reply
        0
        • C ChrisW67
          6 Jul 2021, 00:15

          Like QPushButton::setFlat() only for QToolButton? QToolButton does not seem to have an equivalent.

          S Offline
          S Offline
          Saviz
          wrote on 6 Jul 2021, 15:21 last edited by
          #5

          @ChrisW67

          I am not sure. When I press the button it sinks, I don't like that. Is it possible to stop that with style sheets?

          M 1 Reply Last reply 6 Jul 2021, 15:30
          0
          • S Saviz
            6 Jul 2021, 15:21

            @ChrisW67

            I am not sure. When I press the button it sinks, I don't like that. Is it possible to stop that with style sheets?

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 6 Jul 2021, 15:30 last edited by
            #6

            @Saviz
            well yes if you style it.

            QToolButton {
                border: 2px solid #8f8f91;
                border-radius: 6px;
                background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                  stop: 0 #f6f7fa, stop: 1 #dadbde);
            }
            
            QToolButton:pressed {
                background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                  stop: 0 #f6f7fa, stop: 1 #dadbde);
            }
            
            

            alt text

            S 1 Reply Last reply 6 Jul 2021, 18:01
            0
            • M mrjj
              6 Jul 2021, 15:30

              @Saviz
              well yes if you style it.

              QToolButton {
                  border: 2px solid #8f8f91;
                  border-radius: 6px;
                  background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                    stop: 0 #f6f7fa, stop: 1 #dadbde);
              }
              
              QToolButton:pressed {
                  background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                    stop: 0 #f6f7fa, stop: 1 #dadbde);
              }
              
              

              alt text

              S Offline
              S Offline
              Saviz
              wrote on 6 Jul 2021, 18:01 last edited by Saviz 7 Jun 2021, 18:02
              #7

              @mrjj

              Exactly as the image shows there is a tiny noticeable animation that the button does. It seems as if the three dots (...) are sinking. Can I get rid of that?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 6 Jul 2021, 18:38 last edited by
                #8

                Then why use a button at all if you in fact don't want a button ?

                Create your own clickable widget, it will be simpler than trying to get rid of what makes a button behave like a button.

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

                S 1 Reply Last reply 7 Jul 2021, 10:35
                1
                • S SGaist
                  6 Jul 2021, 18:38

                  Then why use a button at all if you in fact don't want a button ?

                  Create your own clickable widget, it will be simpler than trying to get rid of what makes a button behave like a button.

                  S Offline
                  S Offline
                  Saviz
                  wrote on 7 Jul 2021, 10:35 last edited by Saviz 7 Jul 2021, 10:37
                  #9

                  @SGaist 7UTgkvSGs7.gif

                  Since I can't explain it correctly I decided to add a video to demonstrate the problem.

                  As you can see In my side bar the QToolButton sinks way too much and I don't like that. Many apps have it so the button is stationary and doesn't do that animation. Is that achievable?

                  (What's wrong with wanting a button that dose not sink ? :/ The QPushButton doesn't do that as well.)

                  M 1 Reply Last reply 7 Jul 2021, 10:53
                  0
                  • S Saviz
                    7 Jul 2021, 10:35

                    @SGaist 7UTgkvSGs7.gif

                    Since I can't explain it correctly I decided to add a video to demonstrate the problem.

                    As you can see In my side bar the QToolButton sinks way too much and I don't like that. Many apps have it so the button is stationary and doesn't do that animation. Is that achievable?

                    (What's wrong with wanting a button that dose not sink ? :/ The QPushButton doesn't do that as well.)

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 7 Jul 2021, 10:53 last edited by
                    #10

                    @Saviz

                    Hi
                    Not showing when the button is activated is not optimal as some,
                    including me, will think it's not active
                    and just not painted dark enough as disabled
                    due to the new design style that is most mono-color so disabled buttons are hard(er) to spot.

                    You can use a proxy style to disable the "press" effect

                    class ToolButtonProxy : public QProxyStyle {
                    public:
                      int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override {
                        int ret = 0;
                        switch (metric) {
                          case QStyle::PM_ButtonShiftHorizontal:
                          case QStyle::PM_ButtonShiftVertical:
                            ret = 0;
                            break;
                          default:
                            ret = QProxyStyle::pixelMetric(metric, option, widget);
                            break;
                        }
                        return ret;
                      }
                    };
                    
                    

                    ui->MYBUTT->setStyle( new ToolButtonProxy() );

                    S 1 Reply Last reply 7 Jul 2021, 11:08
                    2
                    • M mrjj
                      7 Jul 2021, 10:53

                      @Saviz

                      Hi
                      Not showing when the button is activated is not optimal as some,
                      including me, will think it's not active
                      and just not painted dark enough as disabled
                      due to the new design style that is most mono-color so disabled buttons are hard(er) to spot.

                      You can use a proxy style to disable the "press" effect

                      class ToolButtonProxy : public QProxyStyle {
                      public:
                        int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override {
                          int ret = 0;
                          switch (metric) {
                            case QStyle::PM_ButtonShiftHorizontal:
                            case QStyle::PM_ButtonShiftVertical:
                              ret = 0;
                              break;
                            default:
                              ret = QProxyStyle::pixelMetric(metric, option, widget);
                              break;
                          }
                          return ret;
                        }
                      };
                      
                      

                      ui->MYBUTT->setStyle( new ToolButtonProxy() );

                      S Offline
                      S Offline
                      Saviz
                      wrote on 7 Jul 2021, 11:08 last edited by
                      #11

                      @mrjj

                      Thank you, that solved my problem. :)

                      1 Reply Last reply
                      0

                      11/11

                      7 Jul 2021, 11:08

                      • Login

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