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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on 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

    SavizS 1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #3

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

      SavizS 1 Reply Last reply
      0
      • SGaistS SGaist

        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.

        SavizS Offline
        SavizS Offline
        Saviz
        wrote on 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

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

          SavizS Offline
          SavizS Offline
          Saviz
          wrote on 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?

          mrjjM 1 Reply Last reply
          0
          • SavizS Saviz

            @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?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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

            SavizS 1 Reply Last reply
            0
            • mrjjM mrjj

              @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

              SavizS Offline
              SavizS Offline
              Saviz
              wrote on last edited by Saviz
              #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
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 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

                SavizS 1 Reply Last reply
                1
                • SGaistS SGaist

                  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.

                  SavizS Offline
                  SavizS Offline
                  Saviz
                  wrote on last edited by Saviz
                  #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.)

                  mrjjM 1 Reply Last reply
                  0
                  • SavizS Saviz

                    @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.)

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 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() );

                    SavizS 1 Reply Last reply
                    2
                    • mrjjM mrjj

                      @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() );

                      SavizS Offline
                      SavizS Offline
                      Saviz
                      wrote on last edited by
                      #11

                      @mrjj

                      Thank you, that solved my problem. :)

                      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