[Qt-interest] painting on graphicsviews in real time

Mihail Naydenov mlists at ymail.com
Wed Jun 9 08:58:41 CEST 2010


You was given general directions already, but I it is assumed you have some knowledge about the topic.

I suggest you give it a break for few days, and study both the samples 
and the docs related to The Graphics View Framework.
Its really not hard at all, and you will get broader understanding of the topic, because right now its evident you dont have much experience .
(For instance in DisplayImage I dont see a reason to addItem and to setScene every time) Just study the samples to see how its done.

thumbs up
MihailNaydenov

>
>From: caius ligarius <caius9090 at gmail.com>
>To: Qt Interest <qt-interest at trolltech.com>
>Sent: Wed, June 9, 2010 3:57:48 AM
>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
>
>
>


      



More information about the Qt-interest-old mailing list