[Qt-interest] Painting outside QWidget::paintEvent() on MS Windows
Srdjan Todorovic
todorovic.s at googlemail.com
Sat Jun 13 12:56:54 CEST 2009
Hi,
2009/6/13 varun singh <mailthatmale at yahoo.co.in>:
>
> hi,
> I've started learning Qt on Microsoft Windows platform.
>
> Qt on Windows does not allow painting outside QWidget::paintEvent(). But I want to draw a pixel specified by the click of the mouse (which could have been done using QWidget::mousePressEvent(), had Qt allowed painting outside
> QWidget::paintEvent()).
>
> So, how can I do that?
Make your mouse click event cause a paint event. Then paint in your
paintEvent().
As in:
yourclass::mousePressEvent()
{
mMessage = "Hello!"; /* mMessage is a class member of type QString */
update(); /* should cause a repaint */
}
yourclass::paintEvent()
{
qWarning(mMessage.toAscii()); /* mMessage has been modified in
mousePressEvent() */
}
Something like the above?
Srdjan
More information about the Qt-interest-old
mailing list