[Qt-interest] Drawing a rect around a QCheckBox
Ulf-Alexander v. Ceumern-Lindenstjerna
ceumern at vrmagic.com
Wed Sep 16 12:09:33 CEST 2009
Hi Giacomo.
What happens exactly? Is the code executed? Does the rect have the
correct position and size?
Is the checkbox maybe drawn on top of the rect?
Regards, Ulf
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Giacomo
> Sent: Wednesday, September 16, 2009 11:11 AM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] Drawing a rect around a QCheckBox
>
> Hi to all!
>
> I want to draw a rect around a QCheckbox.
>
> The code is as follows
>
> else if(event->type() == QEvent::Paint) /* inside a paint event */
> {
> QPaintEvent *paintEvent = static_cast<QPaintEvent*> (event);
>
> if(paintEvent)
> {
> QPainter painter(d_widget); /* d_widget is a checkbox */
> qDebug() << "widget rect: " << d_widget->rect();
> QColor color = Qt::blue;
> QPen pen(color);
> pen.setWidth(2);
> painter.setPen(pen);
> QRect r = d_widget->rect();
> painter.drawRect(r)
> return false;/* do not filter out the event */
> }
> }
>
> While the code works fine on all other widgets i apply it (push
> buttons,
> QLabels...) in the checkbox no way.
>
> Thanks for any hint.
>
> Giacomo.
>
> ing. Giacomo Strangolino
> Elettra - Synchrotron Radiation Facility - Trieste, Italy
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list