How to set the shape of push button /tool button. ? say to oval or round shape
Thanks in advance
How to set the shape of push button /tool button. ? say to oval or round shape
Thanks in advance
Subclass and reimplement the paint event.
Another way is to write a new QStyle that styles only pushbuttons, and set set that style for the pushbuttons in question.
this is the way that I chose to subclass my buttons to get them to look like little green round "electrodes" in an electrode array
Qt Code:
{ grad.setColorAt(0.0, Qt::white); grad.setColorAt(0.1, Qt::green); grad.setColorAt(0.7, Qt::black); painter.setBrush(brush); painter.drawEllipse(2,2,20,20); }To copy to clipboard, switch view to plain text mode
ElectrodeButton is a subclass of QPushButton
MarkoSan (21st January 2008)
Is it possible to adapt button shape dynamically according to loaded icon? What I want to achieve is when button icon is loaded, it's size and shape is reset to size and shape of overlaping icon. How do I do it?
Qt 5.3 Opensource & Creator 3.1.2
It might be simplest to reimplement the paintEvent from the button. An alternative is to create a custom widget and provide an icon setting method that will also change the mask of the widget.
Ok, but how do I extract icon shape? For size, I can use QIcon::actualSize?
Qt 5.3 Opensource & Creator 3.1.2
MarkoSan (22nd January 2008)
Can you provide me with simple example, please?
Qt 5.3 Opensource & Creator 3.1.2
An example of what? Calling createHeuristicMask?
I did not get to step where I will use Calling createHeuristicMask yet. Right now, I have a big pixmap on disk (512x512) an when I set it in QPushButton it is so tiny it can be barely seen. I would like to resize it. How do I do that? I trided rescled, does not work. I tried to put some huge text near this pixmap in button, text is shown ok, pixmap is still tiny.
Shit, I've mixed up threads. I've posted new thread regarding how to resize icon in subclassed qpushbutton. Can you move it?
Qt 5.3 Opensource & Creator 3.1.2
Bookmarks