The question about the size of QPushButton,maybe about QWidget..

  • Yesterday,i try to product a QPushButton that's very common, I limit QPushButton's size by some funtions.
    and then I put it on a QWidget by QHBoxLayout.

    When I tretching the QWidget ,the QPushButton also change its size in a certain range(MAX100,MIN50).

    Now the problem is coming....In the initial plan , I want to this QPushButton always keep the spuare,in other words,I hope QPushButton's width always equal QPushButton's height .But in fact ,the QPushButton is always a rectangel in most of time.

    I looking for the answer in internet and QT assistant.QPushButton(mayby QWidget) can return its own width and height alone,but i don't know how to set uo its width and height alone.

    How can i keep it's(QPushButton) width always equal its height when it changes it's size?

  • Lifetime Qt Champion


    It's been a long time but IIRC you can subclass QPushButton and reimplement "heightForWidth":

    Hope it helps

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.