[Qt-interest] [Qt-Interest] Painting outside paintEvent in QT4.5 : Widget painting can only begin as a result of a paintEvent

shivam priyadarshi shivam.priyadarshi at gmail.com
Sat May 30 23:23:23 CEST 2009


Hi,
I am trying to port a application from QT3.3 to QT4.5. The application
extensively used drawing outside paint event. As for example following is a
drawing example :

void QucsView::MMovePainting(QMouseEvent *Event)
{
   QPainter painter(viewport());
    setPainter(&painter);
    update();
}

Where setPainter function is :
void QucsView::setPainter(QPainter *p)
{
 p->translate(-contentsX(), -contentsY());
 p->setPen(Qt::DotLine);
 p->setCompositionMode(QPainter::RasterOp_NotSource);
}

When i run this i get following warnings on run time

QPainter::begin: Widget painting can only begin as a result of a paintEvent
QPainter::translate: Painter not active
QPainter::setPen: Painter not active

Any workaround to make this code work in QT4.5. I know QT4.5 says all
painting should be done in side paintEvent. If i have many functions doing
painting, does this means all those functions should be called from
paintEvent(QPaintEvent *) function.

I have this kind of code structure at various places in application. I have
tight schedule, it will be great help if you can help me with make it work
with QT4.5 with painting outside paintEvent.

Regards
Shivam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090530/bdffb06d/attachment.html 


More information about the Qt-interest-old mailing list