View Full Version : Graphics view question regarding layouts
MarkoSan
30th November 2009, 20:00
Is it possible to apply QGraphicsGridLayout to QGraphicsView, so the items (including embedded widgets) are layouted just like gui elements on normal widget?
wysota
30th November 2009, 20:38
Yes and no. You can't do that directly but you can place it inside a QGraphicsWidget that takes the whole size of the scene.
MarkoSan
30th November 2009, 20:56
you think it will be possible to directly assign layout in future?
wysota
30th November 2009, 20:59
You can't assign a layout to something that doesn't exist. You need some object. Just like you can't assign a layout to the screen - you need a widget.
MarkoSan
30th November 2009, 21:01
Well, gr. view and gr. scene ARE OBJECTS! Ok, then, widget it is ...
wysota
30th November 2009, 21:09
I don't really see what the problem is with current design...
QGraphicsScene *scene = new QGraphicsScene(QRectF(0,0,1000,500));
QGraphicsWidget *top = new QGraphicsWidget;
QGraphicsLinearLayout *l = new QGraphicsLinearLayout(top);
QGraphicsProxyWidget *w1 = new QGraphicsProxyWidget;
w1->setWidget(new QPushButton);
QGraphicsProxyWidget *w2 = new QGraphicsProxyWidget;
w2->setWidget(new QPushButton);
l->addItem(w1);
l->addItem(w2):
scene->addItem(top);
top->setGeometry(scene->sceneRect());
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.