[Qt-interest] painting on graphicsviews in real time
Jason H
scorp1us at yahoo.com
Wed Jun 9 03:10:44 CEST 2010
Your best bet is probably to make your own QGraphicsItem and just draw on the paint() function, then make sure you call paint() when you need to update it.
Your QGraphicsItem would have all the data (item) that needs to be drawn.
________________________________
From: caius ligarius <caius9090 at gmail.com>
To: Qt Interest <qt-interest at trolltech.com>
Sent: Tue, June 8, 2010 8:57:48 PM
Subject: [Qt-interest] painting on graphicsviews in real time
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/3c606a14/attachment.html
More information about the Qt-interest-old
mailing list