PDA

View Full Version : how to change shape of Qwidget??



anupamgee
24th June 2009, 12:50
hi all,
I want to change the shape of qwidget.I want my widget to have round rectangle shape.
How to do it??

Lykurg
24th June 2009, 12:52
QWidget::setMask()?

anupamgee
25th June 2009, 09:10
hi,
I have tried setMask but didnt get the desired result
How can i do it .Can you explain more.

spirit
25th June 2009, 09:28
did you see an example in QTDIR/examples/widgets/shapedclock?

freezeblue
29th June 2009, 10:54
Here is my example:


void ShapedMenu::roundCorner()
{
QPixmap pixmap(size());
QPainter painter(&pixmap);
painter.fillRect(pixmap.rect(), Qt::white);
painter.setBrush(Qt::black);
painter.drawRoundRect(pixmap.rect(), 10, 10);
setMask(pixmap.createMaskFromColor(Qt::white));
}

You could customize the pixmap by design it with Photoshop, CorelDRAW, etc.