PDA

View Full Version : reimplement QPushButton



kito
18th April 2012, 11:08
How do i reimplement QPushButton such that its shape is a circle not rectangular

ChrisW67
19th April 2012, 01:04
You should exhaust the possibilities of using style sheets to gain the desired look first. If that cannot do it then subclass QPushButton and re-implement QWidget::paintEvent() to draw the widget however you want. You would also need to provide appropriate size hints.

Jonny174
19th April 2012, 07:30
Take class AeroButton. Use setRoundness( int roundness ) [0 - rectangle, 99 - oval]

kito
19th April 2012, 13:55
everything seems ok except the size,i did reimplemented sizeHint() but i dont know where to put the call. my widget takes the size of the parent(QPushButton)

ChrisW67
20th April 2012, 02:53
The sizeHint() function will be called by the layout the widget is in (or when the widget is shown for top level widgets). You don't have to call it explicitly.

kito
20th April 2012, 08:41
Thank you every much.I am aware of that.everything working fine now.