PDA

View Full Version : QWidget, only draw outline!



kinglui987
16th May 2013, 17:05
Hey,


is there a way to only draw the outline of a QWidget? I tried to find a example, but could not find one yet.

I want only to draw a circle with no fill? The innercircle should be transparent!

Any clues about that?

Thanks in advance

wysota
16th May 2013, 20:06
setBrush(Qt::NoBrush)

kinglui987
16th May 2013, 21:48
Hey,

thanks for your answer, but i am pretty sure that is not that easy.

I want a QWidget, with an appearance of only an outline.
Nothing else then the circumference should be visible. No Background, and the inner circle should alos be transparent, e.g.
show the desktop of the os, or what ever is under the widget.

I am pretty sure, it can be done with setMask().
But i still cannot get it.

Anyone with a good example for making a QWidget with a custom shape as appearance?

Thanks in advance,

ChrisW67
17th May 2013, 02:59
Quite apart from the Shaped Clock Example that ships with Qt... this works fine here:


class Widget: public QWidget
{
Q_OBJECT
public:
Widget(QWidget *p = 0):
QWidget(p)
{
resize(400, 400);
QBitmap pixmap(400, 400);
QPainter painter(&pixmap);
painter.fillRect(pixmap.rect(), Qt::color0);
painter.setPen(QPen(Qt::color1, 2));
painter.drawEllipse(QRect(10, 10, 380, 380));
painter.end();
setMask(pixmap);
}
};

wysota
17th May 2013, 06:26
Hey,

thanks for your answer, but i am pretty sure that is not that easy.
I'm sure it is as easy as clearly expressing your goal. Read your original post again and see if anyone can understand from it what you want.

Even what you posted here is not that clear, look:


I want a QWidget, with an appearance of only an outline.
QWidget is blank.


Nothing else then the circumference should be visible.
QWidget is blank, it has no circumference visible.


No Background
set a transparent brush.


and the inner circle should alos be transparent
What inner circle?


I am pretty sure, it can be done with setMask().
Maybe, hard to say without knowing what you want to do. I would rather put my money on TranslucentBackground attribute.