#include <QtGui>
class LayoutItem : public QGraphicsWidget {
public:
LayoutItem
(QGraphicsItem *parent
= 0) : QGraphicsWidget
( parent
) {}
qDebug() << "LayoutItem::paint, size = " << size();
painter->drawRect( frame );
}
};
class Window : public QGraphicsWidget {
public:
Window(QGraphicsWidget *parent = 0) {
QGraphicsGridLayout *grid = new QGraphicsGridLayout( this );
LayoutItem* item = new LayoutItem;
grid->addItem(item, 0, 0, 1, 1);
item->resize( 400, 400 );
}
};
int main(int argc, char **argv)
{
Window *window = new Window;
scene.addItem(window);
view.resize(500, 500);
view.show();
return app.exec();
}
#include <QtGui>
class LayoutItem : public QGraphicsWidget {
public:
LayoutItem(QGraphicsItem *parent = 0) : QGraphicsWidget( parent ) {}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0) {
qDebug() << "LayoutItem::paint, size = " << size();
QRectF frame(QPointF(0,0), geometry().size());
painter->drawRect( frame );
}
};
class Window : public QGraphicsWidget {
public:
Window(QGraphicsWidget *parent = 0) {
QGraphicsGridLayout *grid = new QGraphicsGridLayout( this );
LayoutItem* item = new LayoutItem;
grid->addItem(item, 0, 0, 1, 1);
item->resize( 400, 400 );
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QGraphicsScene scene;
Window *window = new Window;
scene.addItem(window);
QGraphicsView view(&scene);
view.resize(500, 500);
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks