PDA

View Full Version : problem using qgraphicsview



sandhyarani
31st July 2009, 08:16
QGraphicsScene s;
s.addText("hello"); //s.addRect(0,0,100,100);
QGraphicsView v(&s);
v.show();

i am using qt4.5 , i try to write a simple qt program using qt creator to display a view containing a scene with text or a rectagle , when i run it its displaying only a blank view neither text or a rectangle being drawn.

can any body help

yogeshgokul
31st July 2009, 08:22
This is working fine on my machine.


#include <QApplication>
#include <Qtgui>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene s;
s.addText("hello"); //s.addRect(0,0,100,100);
QGraphicsView v(&s);
v.show();
return a.exec();
}

lni
31st July 2009, 13:17
QGraphicsScene s;
s.addText("hello"); //s.addRect(0,0,100,100);
QGraphicsView v(&s);
v.show();

i am using qt4.5 , i try to write a simple qt program using qt creator to display a view containing a scene with text or a rectagle , when i run it its displaying only a blank view neither text or a rectangle being drawn.

can any body help
You sure it doesn't go out of score with everything on stack? Try to put it in heap and see what happen...

yogeshgokul
31st July 2009, 13:30
You sure it doesn't go out of score with everything on stack?
Yes I am, because app.exec() is the barrier here. untill you dont terminate application execution, these objects will be in memory, and the program is running absolutely fine.


Try to put it in heap and see what happen...

Same results.:););)