PDA

View Full Version : Graphicsview??



Screeze
5th July 2009, 17:26
Well, i try to use an graphicsview.
It's located in an dialog form (createt with the designer from qt creator IDE) and called "test".

In the constructor of the form (after m_ui->setupUi(this);) i tried this, to write anything on the gv.



QGraphicsScene scene;
scene.addText("GraphicsView rotated clockwise");

m_ui->test->setScene(&scene);
m_ui->test->rotate(90); // the text is rendered with a 90 degree clockwise rotation
m_ui->test->show();


But it has no effect. The graphicsview is still empty.
What am I doing wrong?

Thanks

wysota
5th July 2009, 17:33
You are creating a local object of type QGraphicsScene that gets destroyed once you leave the constructor so you see nothing. Create the scene on heap instead of the stack.

Screeze
5th July 2009, 18:01
thanks, that was the problem..


QGraphicsScene *graphicsScene = new QGraphicsScene(this);

now works fine...

Thank you ;)