PDA

View Full Version : QGraphicsScene problem/bug



rubenvb
27th September 2009, 17:36
Taken directly from the Qt 4.5.2 documentation, in the Detailed Description of QGraphicsGridLayout:



QGraphicsScene scene;
QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);

QGraphicsGridLayout *layout = new QGraphicsGridLayout;
layout->addItem(textEdit, 0, 0);
layout->addItem(pushButton, 0, 1);

QGraphicsWidget *form = new QGraphicsWidget;
form->setLayout(layout);
scene.addItem(form);


First problem: I don't see anything if I wrap this in a simple QApplication:

int main()
{
QApplication app();

QWidget *widget;
//the above code, with the first line:
//QGraphicsScene scene(widget);
widget->show();
return app.exec();
}

This structure is really important, but when I try to implement it in my class's constructor, it won't compile. What's wrong here? Thanks!

Lykurg
27th September 2009, 22:40
..you don't see anything because you have to show the scene or set it to your widget, using layouts!

int main()
{
QApplication app();
//the above code
scene.show();
return app.exec();
}

wysota
28th September 2009, 00:34
It might be worth actually having a QGraphicsView somewhere...