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/qpushbutton icon based on button's size

qtoolbutton/qpushbutton icon based on button's size

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 2 Posters 8.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.
  • U Offline
    U Offline
    user4592357
    wrote on 22 Dec 2018, 19:22 last edited by
    #12

    @mrjj
    i managed to do that but i want to remove all spaces between buttons.
    i've set setContentsMargins(0, 0, 0, 0) and setSpacing(0) for the layout.
    this is what i have now: https://ibb.co/qYCm8vR
    can't i remove those spaces?

    M 1 Reply Last reply 22 Dec 2018, 19:42
    0
    • U user4592357
      22 Dec 2018, 19:22

      @mrjj
      i managed to do that but i want to remove all spaces between buttons.
      i've set setContentsMargins(0, 0, 0, 0) and setSpacing(0) for the layout.
      this is what i have now: https://ibb.co/qYCm8vR
      can't i remove those spaces?

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 22 Dec 2018, 19:42 last edited by
      #13

      @user4592357
      Hi
      The tool buttons seems to reserve some pixels so there will be a small space.
      alt text

      The lower ones are Frames and both layouts have same settings so its fair to say
      its the closest you get with ToolButtons as seen in top.

      1 Reply Last reply
      0
      • U Offline
        U Offline
        user4592357
        wrote on 24 Dec 2018, 14:59 last edited by
        #14

        @mrjj
        hi,
        when i add the buttons to a layout, they take up more space (just because it's available).
        how can i make the buttons be in their minimum size in that layout?

        p.s. this is what i have set for the button:

        setMinimumSize(...);
        setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
        
        M 1 Reply Last reply 24 Dec 2018, 15:02
        0
        • U user4592357
          24 Dec 2018, 14:59

          @mrjj
          hi,
          when i add the buttons to a layout, they take up more space (just because it's available).
          how can i make the buttons be in their minimum size in that layout?

          p.s. this is what i have set for the button:

          setMinimumSize(...);
          setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
          
          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 24 Dec 2018, 15:02 last edited by
          #15

          @user4592357
          But would would be the minimum ?
          You can set setMaximumSize of them if you want to limit it to
          certain size. like 64x64. else layout makes them use the extra space.

          U 1 Reply Last reply 24 Dec 2018, 15:32
          0
          • M mrjj
            24 Dec 2018, 15:02

            @user4592357
            But would would be the minimum ?
            You can set setMaximumSize of them if you want to limit it to
            certain size. like 64x64. else layout makes them use the extra space.

            U Offline
            U Offline
            user4592357
            wrote on 24 Dec 2018, 15:32 last edited by user4592357
            #16

            @mrjj
            no i don't want max size...
            i thought i could add a spacer at column 0 and last column, and set stretch factor to those columns

            M 1 Reply Last reply 24 Dec 2018, 15:42
            0
            • U user4592357
              24 Dec 2018, 15:32

              @mrjj
              no i don't want max size...
              i thought i could add a spacer at column 0 and last column, and set stretch factor to those columns

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 24 Dec 2018, 15:42 last edited by mrjj
              #17

              @user4592357
              im not sure i understand.
              You do not want a max size for widgets but at same time they are not allowed to use
              all the space ?
              well yes spacers should compress to minimum

              1 Reply Last reply
              0
              • U Offline
                U Offline
                user4592357
                wrote on 24 Dec 2018, 15:51 last edited by
                #18

                yes maybe that's weird but that's what i need.
                when i added the spacer at col 0, and then the rest of the widgets, only the first widget got added.

                M 1 Reply Last reply 24 Dec 2018, 15:57
                0
                • U user4592357
                  24 Dec 2018, 15:51

                  yes maybe that's weird but that's what i need.
                  when i added the spacer at col 0, and then the rest of the widgets, only the first widget got added.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 24 Dec 2018, 15:57 last edited by
                  #19

                  @user4592357
                  Im not sure what you mean . Adding cant fail due to spacer.
                  did you set Minimum on the widgets as else they get compressed totally.

                  alt text

                  with no Minimum set
                  alt text

                  1 Reply Last reply
                  0
                  • U Offline
                    U Offline
                    user4592357
                    wrote on 24 Dec 2018, 16:57 last edited by user4592357
                    #20

                    i added spacers at both ends of hbox layout, but now the whole container widget gets larger instead of the buttons getting smaller (since there is a spacer around them)...

                    M 1 Reply Last reply 25 Dec 2018, 00:03
                    0
                    • U user4592357
                      24 Dec 2018, 16:57

                      i added spacers at both ends of hbox layout, but now the whole container widget gets larger instead of the buttons getting smaller (since there is a spacer around them)...

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 25 Dec 2018, 00:03 last edited by
                      #21

                      @user4592357
                      Hi
                      Its impossible to guess at with no code or pictures.
                      If i do the same with Horz layout i get this
                      alt text

                      1 Reply Last reply
                      1

                      21/21

                      25 Dec 2018, 00:03

                      • Login

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