[Qt-interest] painting on graphicsviews in real time

caius ligarius caius9090 at gmail.com
Wed Jun 9 02:57:48 CEST 2010


I am still struggling to find a solution to my problem. I basically have a
QGraphicsView widget which  displays a QImage. I call a "Process" function
when a button is pressed. This function basically calculates some line
co-ordinates w.r.t to the QImage which I would like to draw on the viewport
in real time.

Pseudo code below to display QImage-

void Class:: DisplayImage(QImage* currImg)
{
     QPixmap np = QPixmap::fromImage(*currImg);
     graphicpixmapitem->setPixmap(np); //QGraphicPixmapItem Class
     graphicsscene->setSceneRect(0, 0, currImg->width(), currImg->height());
//QGraphicsSceneClass
     graphicsscene->addItem(graphicitemSingleView);

     ui.graphicsView->setScene(graphicssceneSingleView);//QGraphicsView
Class
     ui.graphicsView->show();
}


void Class:: Process()
{
    QLine line1(x,x,x,x)
    <draw line1 on viewport>
....
....
....
    QLine line2(x,x,x,x)
    <draw line2 on viewport>
....
....
...cont....
}

Can somebody give me an example on how to go about implementing this? I am
assuming I should be able to paint on the viewport and update it relatively
quickly with minimal delay. I guess I need to use QPainter somewhere but I
am confused about where to implement and call it so that the viewport is
updated with the new line.If possible please send me some sample pseudo
code.

Thanks,
Caius
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100608/b6cb3e9f/attachment.html 


More information about the Qt-interest-old mailing list