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. Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.

Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 704 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.
  • A Offline
    A Offline
    AlexNevskiy
    wrote on last edited by AlexNevskiy
    #1

    Hello all!

    Imagine that I want all buttons in my prog to have a nice gradient look. And I use a global app stylesheet for this purpose. But something not understandable is going on when I'm trying to control the buttons' background through it.

    If I have buttons in horizontal layout with spacer, and set the next app stylesheet

    QPushButton {
        background: lightblue; 
        border: 1px solid blue; /* need for full overpainting */
    }
    

    then widths of all of the buttons flow away, and buttons with a little text become very small.

    If I add a line to the stylesheet:

    min-width: 80px;
    

    or, just

    width: 80px;
    

    then buttons with small text become ok, but buttons with long text not expand and their texts are partially hidden.

    So, how to change background for all buttons and not to break its dimensions?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tink
      wrote on last edited by
      #2

      Perhaps add some padding. E.g. padding: 5px;

      T A 2 Replies Last reply
      0
      • T Tink

        Perhaps add some padding. E.g. padding: 5px;

        T Offline
        T Offline
        Tink
        wrote on last edited by
        #3

        Or perhaps a large maximum width.

        A 1 Reply Last reply
        0
        • T Tink

          Perhaps add some padding. E.g. padding: 5px;

          A Offline
          A Offline
          AlexNevskiy
          wrote on last edited by
          #4

          @Tink I tried paddings, it didn't help me.

          1 Reply Last reply
          0
          • T Tink

            Or perhaps a large maximum width.

            A Offline
            A Offline
            AlexNevskiy
            wrote on last edited by AlexNevskiy
            #5

            @Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:

            Or perhaps a large maximum width.

            then all the buttons will be unnecessary large

            T 1 Reply Last reply
            0
            • A AlexNevskiy

              @Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:

              Or perhaps a large maximum width.

              then all the buttons will be unnecessary large

              T Offline
              T Offline
              Tink
              wrote on last edited by
              #6

              @AlexNevskiy hmm... perhaps you need to change the sizePolicy?

              A 1 Reply Last reply
              0
              • A Offline
                A Offline
                AlexNevskiy
                wrote on last edited by
                #7

                So, I have found some sort of solution. Just need to set width of expanding spacer to minimum (0 for example). And it works some how.

                T 1 Reply Last reply
                1
                • T Tink

                  @AlexNevskiy hmm... perhaps you need to change the sizePolicy?

                  A Offline
                  A Offline
                  AlexNevskiy
                  wrote on last edited by
                  #8

                  @Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:

                  @AlexNevskiy hmm... perhaps you need to change the sizePolicy?

                  Which policy will make it work?

                  T 1 Reply Last reply
                  0
                  • A AlexNevskiy

                    So, I have found some sort of solution. Just need to set width of expanding spacer to minimum (0 for example). And it works some how.

                    T Offline
                    T Offline
                    Tink
                    wrote on last edited by
                    #9

                    @AlexNevskiy said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:

                    So, I have found some sort of solution. Just need to set width of expanding spacer to minimum (0 for example). And it works some how.

                    Makes sense.

                    1 Reply Last reply
                    0
                    • A AlexNevskiy

                      @Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:

                      @AlexNevskiy hmm... perhaps you need to change the sizePolicy?

                      Which policy will make it work?

                      T Offline
                      T Offline
                      Tink
                      wrote on last edited by
                      #10

                      @AlexNevskiy said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:

                      @Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:

                      @AlexNevskiy hmm... perhaps you need to change the sizePolicy?

                      Which policy will make it work?

                      Well i have most of my widgets on preferred since i dont understand the effects well enough:)
                      But if you add a pushbutton in designer it has horizontal: minimum.

                      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