[Qt-interest] Drawing on a QWidget outside of its PaintEvent

Jason H scorp1us at yahoo.com
Sun Mar 28 22:32:19 CEST 2010


Subclass that widget, call the base-class paint in the paint event, then do your custom drawing.

What you are trying to do violates OOP principals, that's why you're having a hard time with it.



----- Original Message ----
From: Keiver Hdez Fdez <khfernandez at uci.cu>
To: qt-interest at trolltech.com
Sent: Sun, March 28, 2010 4:28:29 PM
Subject: [Qt-interest] Drawing on a QWidget outside of its PaintEvent


I have a QWidget inside the main widget of my application and I want to paint
on it, not on the main one.

The thing is that I get this error:

QPainter::begin: Paint device returned engine == 0, type: 1

I know that this is because I can paint only inside the PaintEvent, but the one I
have belongs to the main widget. The questions is, how can I paint on that other
widget?

Something else:
...
{
    QPainter painter(ui->widgetParticiones);// This widget is the one I want to paint.

    painter.setPen(Qt::blue);

    painter.setBrush(Qt::white);

    painter.drawRect(...);
}

Saludos,
Ing. Keiver Hdez Fdez.
_______________________________________________
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