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. remove space around qToolButton
Forum Updated to NodeBB v4.3 + New Features

remove space around qToolButton

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 3 Posters 1.7k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    jkwok678
    wrote on 9 Jun 2020, 20:05 last edited by
    #3

    Is that done in the designer? I've been hand-coding it so far, and the only methods I've seen is set Max & Min height & width.

    M 1 Reply Last reply 10 Jun 2020, 06:12
    0
    • J jkwok678
      9 Jun 2020, 20:05

      Is that done in the designer? I've been hand-coding it so far, and the only methods I've seen is set Max & Min height & width.

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 10 Jun 2020, 06:12 last edited by
      #4

      @jkwok678
      Hi
      Yes 100% Designer.
      Just properties.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jkwok678
        wrote on 10 Jun 2020, 09:24 last edited by
        #5

        Is there a way to replicate this in code ?

        M 1 Reply Last reply 10 Jun 2020, 09:46
        0
        • J jkwok678
          10 Jun 2020, 09:24

          Is there a way to replicate this in code ?

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 10 Jun 2020, 09:46 last edited by
          #6

          @jkwok678

          yes. open setupUI() you see in mainwindow constructor.
          You can press F2 on the name to go there
          then you can take the code.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Bonnie
            wrote on 10 Jun 2020, 09:57 last edited by
            #7

            @jkwok678 I'm not sure about this, but does setAutoRaise(true) act as you expected?

            J 1 Reply Last reply 10 Jun 2020, 11:42
            1
            • J Offline
              J Offline
              jkwok678
              wrote on 10 Jun 2020, 11:29 last edited by
              #8

              @mrjj
              Ah, I think you misinterpreted what I mean, I've hand coded all the buttons and didn't use a ui file.
              So I want to try replicate your button that i saw in the image using code.

              M 1 Reply Last reply 10 Jun 2020, 11:40
              0
              • J jkwok678
                10 Jun 2020, 11:29

                @mrjj
                Ah, I think you misinterpreted what I mean, I've hand coded all the buttons and didn't use a ui file.
                So I want to try replicate your button that i saw in the image using code.

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 10 Jun 2020, 11:40 last edited by
                #9

                @jkwok678
                Yes i fairly sure i did :)
                its
                button1->setFixedSize(100,100);
                button1->setIconSize(QSize(100, 100));

                for 100x100 icon / button

                J 1 Reply Last reply 10 Jun 2020, 12:18
                0
                • B Bonnie
                  10 Jun 2020, 09:57

                  @jkwok678 I'm not sure about this, but does setAutoRaise(true) act as you expected?

                  J Offline
                  J Offline
                  jkwok678
                  wrote on 10 Jun 2020, 11:42 last edited by
                  #10

                  @Bonnie
                  Thanks for the suggestion, it works in a way, but once the button is highlighted you can still see the border around the QIcon in the QToolButton. So the size of the button is still the same, I was hoping to shrink the size of the button, to being much closer to the size of the QIcon which is 16x16. I would prefer to have maybe 1/2 pixel border around the button. But also allow the button to expand if the screen resolution/ screen size is high.

                  M 1 Reply Last reply 10 Jun 2020, 11:43
                  0
                  • J jkwok678
                    10 Jun 2020, 11:42

                    @Bonnie
                    Thanks for the suggestion, it works in a way, but once the button is highlighted you can still see the border around the QIcon in the QToolButton. So the size of the button is still the same, I was hoping to shrink the size of the button, to being much closer to the size of the QIcon which is 16x16. I would prefer to have maybe 1/2 pixel border around the button. But also allow the button to expand if the screen resolution/ screen size is high.

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 10 Jun 2020, 11:43 last edited by
                    #11

                    @jkwok678 said in remove space around qToolButton:

                    But also allow the button to expand if the screen resolution/ screen size is high.

                    Ok then DONT use setFixedSize to set size but just the normal ones

                    1 Reply Last reply
                    0
                    • M mrjj
                      10 Jun 2020, 11:40

                      @jkwok678
                      Yes i fairly sure i did :)
                      its
                      button1->setFixedSize(100,100);
                      button1->setIconSize(QSize(100, 100));

                      for 100x100 icon / button

                      J Offline
                      J Offline
                      jkwok678
                      wrote on 10 Jun 2020, 12:18 last edited by
                      #12

                      @mrjj
                      With this implementation is the setFixedSize more of a default/intitial size?
                      So when I have code that allows the button to resize, it can still do so?

                      M 1 Reply Last reply 10 Jun 2020, 12:30
                      0
                      • J jkwok678
                        10 Jun 2020, 12:18

                        @mrjj
                        With this implementation is the setFixedSize more of a default/intitial size?
                        So when I have code that allows the button to resize, it can still do so?

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 10 Jun 2020, 12:30 last edited by
                        #13

                        @jkwok678 said in remove space around qToolButton:

                        setFixedSize

                        Will set to a fixed size so nope, it wont resize then
                        so dont use it if you want toolbuttons to grow

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          jkwok678
                          wrote on 10 Jun 2020, 13:33 last edited by
                          #14

                          What's the normal ones? I don't see just a set Size function in the documentation.

                          M 1 Reply Last reply 10 Jun 2020, 13:48
                          0
                          • J jkwok678
                            10 Jun 2020, 13:33

                            What's the normal ones? I don't see just a set Size function in the documentation.

                            M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 10 Jun 2020, 13:48 last edited by
                            #15

                            @jkwok678

                            Hi
                            setGeometry and
                            resize

                            but if you put them in layout anyway, its pointless as then they scale and
                            icon gets border again since now iconSize is not matching anymore.

                            1 Reply Last reply
                            1
                            • J Offline
                              J Offline
                              jkwok678
                              wrote on 10 Jun 2020, 15:41 last edited by
                              #16

                              So, what could I do to have the button have the same size as the QIcon, or at least just less blank space?

                              M 1 Reply Last reply 10 Jun 2020, 15:42
                              0
                              • J jkwok678
                                10 Jun 2020, 15:41

                                So, what could I do to have the button have the same size as the QIcon, or at least just less blank space?

                                M Offline
                                M Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 10 Jun 2020, 15:42 last edited by
                                #17

                                @jkwok678
                                well
                                button1->setFixedSize(100,100);
                                button1->setIconSize(QSize(100, 100));
                                set button to 100x100 and same with icon.
                                botton stay that size.

                                1 Reply Last reply
                                1
                                • J Offline
                                  J Offline
                                  jkwok678
                                  wrote on 10 Jun 2020, 17:08 last edited by
                                  #18

                                  Would it be able to do that and also expand?As in when the button expands the Icon could expand as well? Or perhaps switch to a different Icon that us higher resolution?

                                  M 1 Reply Last reply 10 Jun 2020, 17:19
                                  0
                                  • J jkwok678
                                    10 Jun 2020, 17:08

                                    Would it be able to do that and also expand?As in when the button expands the Icon could expand as well? Or perhaps switch to a different Icon that us higher resolution?

                                    M Offline
                                    M Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on 10 Jun 2020, 17:19 last edited by mrjj 6 Oct 2020, 17:22
                                    #19

                                    Hi
                                    Sadly no.
                                    If you want such things, make a custom button that does it.

                                    However, Qt has support for HIRES displays that do scaling etc.
                                    and QIcon can have hires version to be used on such displays
                                    https://doc.qt.io/qt-5/highdpi.html

                                    but this has nothing to do with you want icon to cover all of the button at all times :)
                                    That is not a hires thing, in my opinion :)

                                    here is example of custom button
                                    https://stackoverflow.com/questions/31742194/dynamically-resize-qicon-without-calling-setsizeicon

                                    It scales the cion to fit at any given time.
                                    As you can see its not much code.

                                    1 Reply Last reply
                                    0

                                    12/19

                                    10 Jun 2020, 12:18

                                    • Login

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