Michael Quigley wrote:
> Hello!
>
> I'm a relatively new Qt Jambi user. I've been ramping up over the last few
> days, but I've run into a problem that I can't seem to get around.
>
> Here is the code:
>
> ----8<----
>
> package com.quigley.qt.editor;
>
> import com.trolltech.qt.gui.*;
>
> public class Editor extends QMainWindow {
> protected QStatusBar statusBar;
>
> public Editor() {
> QGraphicsScene scene = new QGraphicsScene();
> scene.addText("Hello World");
>
> QGraphicsView view = new QGraphicsView(scene);
> this.setCentralWidget(view);
>
> statusBar = new QStatusBar();
> this.setStatusBar(statusBar);
> }
>
> public static void main(String[] args) {
> QApplication.initialize(args);
> Editor editor = new Editor();
> editor.show();
> QApplication.exec();
> }
> }
>
> ----8<----
>
> When I run this, I see the text "Hello World" get painted onto the
> QGraphicsView, but then it's immediately overwritten with plain white.
Hi Michael,
The reason for the problem is a bit of GC confusion, unfortunately. The
QGraphicsView doesn't take ownership of the QGraphicsScene so at a
random point the scene object will be collected and the view has no
scene and this renders empty.
This is fixed if you keep a reference to the scene.
-
Gunnar
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest