PDA

View Full Version : Customise QPushButton shape



ataffard
21st March 2008, 12:47
Hi,

I'm trying to make my own QPushButton with customized shape (circle, triangle etc of various dimension and color).
I started by writing a class inheriting from QPushButton and rewriting the paintEvent, but I'm not managing to getting it to work properly. It doesn't look like a button anymore, cannot be clicked etc...

Could anyone send some advice on how to do this.

Cheers
Anyes

vql
21st March 2008, 13:16
Please see examples in Qt Demo, direct to Widgets->Style. This is a example about a customized style, it helps you how to create a customized push button & more ...

ataffard
21st March 2008, 20:41
Hi,

This example change the whole style of the application and reimplement a different PE_PanelButtonCommand.
I don't see how I can make coexist buttons of different shapes within the same window application using this.

JimDaniel
22nd March 2008, 06:02
Recently I subclassed a QPushButton and re-implemented its paint event to draw my own Vista-style glass button. The code is on the wiki, here:

http://wiki.qtcentre.org/index.php?title=AeroButton

Its not exactly what you need I know, but maybe you can see by my example how you can draw your own buttons.