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 correctly set push button style when pressed?
QtWS25 Last Chance

How to correctly set push button style when pressed?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 7.7k 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.
  • T Offline
    T Offline
    testevpsa
    wrote on 25 Jun 2018, 16:35 last edited by
    #1

    Hello, I'm new to Qt and I'm using Qt Designer.

    My Problem is:
    I'm unable to set a style to a push button when it is pressed. See the image below:
    0_1529944422963_0d03a4c0-4f20-470c-89c6-9c39fcbd4513-image.png

    The stylesheet pressed state has no effect on the button, does anyone see what I am doing wrong?

    Thank you for your time, have a good day!

    G 1 Reply Last reply 25 Jun 2018, 18:35
    0
    • T testevpsa
      25 Jun 2018, 16:35

      Hello, I'm new to Qt and I'm using Qt Designer.

      My Problem is:
      I'm unable to set a style to a push button when it is pressed. See the image below:
      0_1529944422963_0d03a4c0-4f20-470c-89c6-9c39fcbd4513-image.png

      The stylesheet pressed state has no effect on the button, does anyone see what I am doing wrong?

      Thank you for your time, have a good day!

      G Offline
      G Offline
      Gojir4
      wrote on 25 Jun 2018, 18:35 last edited by
      #2

      @testevpsa Hi,

      Maybe your first 4 lines overrides the other definitions because they are global. Try to enclose them in QPushButton{...}

      QPushButton {
          background-color: rgb(51, 153, 204);
          ...
      }
      QPushButton:pressed {
          background-color: rgb(224, 0, 0);
          ...
      }
      
      T A 2 Replies Last reply 25 Jun 2018, 19:10
      2
      • G Gojir4
        25 Jun 2018, 18:35

        @testevpsa Hi,

        Maybe your first 4 lines overrides the other definitions because they are global. Try to enclose them in QPushButton{...}

        QPushButton {
            background-color: rgb(51, 153, 204);
            ...
        }
        QPushButton:pressed {
            background-color: rgb(224, 0, 0);
            ...
        }
        
        T Offline
        T Offline
        testevpsa
        wrote on 25 Jun 2018, 19:10 last edited by
        #3

        Hello @Gojir4 , you are completely right!
        Thank you for your help!

        1 Reply Last reply
        0
        • G Gojir4
          25 Jun 2018, 18:35

          @testevpsa Hi,

          Maybe your first 4 lines overrides the other definitions because they are global. Try to enclose them in QPushButton{...}

          QPushButton {
              background-color: rgb(51, 153, 204);
              ...
          }
          QPushButton:pressed {
              background-color: rgb(224, 0, 0);
              ...
          }
          
          A Offline
          A Offline
          Austrolog
          wrote on 23 Aug 2022, 14:21 last edited by
          #4

          @Gojir4 Hi, where did youn find ":pressed"? I tried to search it on the documentation but it doesn't mention about pressed

          J 1 Reply Last reply 23 Aug 2022, 14:31
          0
          • A Austrolog
            23 Aug 2022, 14:21

            @Gojir4 Hi, where did youn find ":pressed"? I tried to search it on the documentation but it doesn't mention about pressed

            J Offline
            J Offline
            JonB
            wrote on 23 Aug 2022, 14:31 last edited by
            #5

            @Austrolog
            https://doc-snapshots.qt.io/qt6-dev/stylesheet-reference.html#list-of-pseudo-states
            https://doc-snapshots.qt.io/qt6-dev/stylesheet-examples.html#customizing-qpushbutton

            A 1 Reply Last reply 23 Aug 2022, 17:30
            2
            • J JonB
              23 Aug 2022, 14:31

              @Austrolog
              https://doc-snapshots.qt.io/qt6-dev/stylesheet-reference.html#list-of-pseudo-states
              https://doc-snapshots.qt.io/qt6-dev/stylesheet-examples.html#customizing-qpushbutton

              A Offline
              A Offline
              Austrolog
              wrote on 23 Aug 2022, 17:30 last edited by
              #6

              @JonB thank you

              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