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. [Solved] Flat and borderless QPushButton does not have the same size as the pixmap
Forum Updated to NodeBB v4.3 + New Features

[Solved] Flat and borderless QPushButton does not have the same size as the pixmap

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 28.0k 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.
  • G Offline
    G Offline
    giesbert
    wrote on last edited by
    #6

    If you post a small example where we can reproduce the problem, we might be able to help.
    But therefore, we need the project files, images etc.

    Nokia Certified Qt Specialist.
    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #7

      here is a "test ui file":http://dl.dropbox.com/u/33544011/dialogTest.ui I created using 2 images. One for normal and one for Clicked state.

      Open the ui file to study what I described above. You should change the png files to yours of course ;)

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hdvision
        wrote on last edited by
        #8

        Here is "the zip file":http://repo.dualalign.net/hi/button-issue.zip enclosing the ui, resource, and image files that I have been playing with. I did not create a project file since what I see in the Designer is consistent with the compiled binary.

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #9

          Did you look into my example? What have you tried? Do you have any questions?

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hdvision
            wrote on last edited by
            #10

            I did. The only difference I saw is that you defined the minimum size and maximum size to be the image dimension. Once I did that in my own example, the widget size now is the same as image dimension.

            I guess it is a way to "force" the button to behave. I am fine with it (for my current work), but still puzzle a bit at its strange behavior (before defining the min and max size).

            1 Reply Last reply
            0
            • EddyE Offline
              EddyE Offline
              Eddy
              wrote on last edited by
              #11

              Yes, I know it's brute force. But what you want to do is not "intended". We eliminate all the decoration of the box model and draw on the margins. Normally your OS is responsible for this and you wanted it differently.
              Your button will not behave visually as a button anymore. That's why I used a second image in my example to have another color which mimics the clicking state.

              So if you consider this topic as solved, could you please add [Solved] in the beginning of your title by editing it?

              Qt Certified Specialist
              www.edalsolutions.be

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hdvision
                wrote on last edited by
                #12

                Before I make the post [Solved], I do want to clarify:

                The only reason why I use only one image in my example for my button is to simplify the case. Normally, in the GUI program I am writing, I would use three images for a button: normal, hover, and clicked states. I have seen many modern programs or even web pages use custom buttons like that.

                I like Qt very much, but I also wish it can be a little more intuitive. For example, if I specify three images for a button, set the pad and margin to be 0, then it shall look exactly like the image. I still do not understand why it "draws on the margins" if the margin is set to 0.

                1 Reply Last reply
                0
                • EddyE Offline
                  EddyE Offline
                  Eddy
                  wrote on last edited by
                  #13

                  Making a framework that works on multiple platforms is not easy. If you are interested to see how the Trolls do it have a look in the sources of the different QStyles. I did it a while ago and noticed lots of "brute force" as you call it. ;)

                  Qt Certified Specialist
                  www.edalsolutions.be

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hdvision
                    wrote on last edited by
                    #14

                    I guess you are right. Thanks for all the help. ;)

                    1 Reply Last reply
                    0
                    • EddyE Offline
                      EddyE Offline
                      Eddy
                      wrote on last edited by
                      #15

                      you're welcome.

                      Just another thought :
                      I noticed a 2 pixel wide white border in your image. You could eliminated this and let Qt handle the normal behaviour.

                      Qt Certified Specialist
                      www.edalsolutions.be

                      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