rubenvb
27th September 2009, 16: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!
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!