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

Keiver Hdez Fdez khfernandez at uci.cu
Sun Mar 28 22:28:29 CEST 2010


 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.



More information about the Qt-interest-old mailing list