The left side(QGraphicsView,QGraphicsLinearLayout based)of the window should behave like the right side(QWidget,QVBoxLayout based) of the window.
This means QTreeWidget and QPushBotton should fill the whole area of QGraphicsView. Also if the window is resized.
Any ideas how to fix this code? Or is there a complete different way?
GraphicWidgetTest
::GraphicWidgetTest(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
// left side
view->setScene(scene);
//scene->setBackgroundBrush(QBrush(QColor(Qt::red)));
QGraphicsLinearLayout *vboxl = new QGraphicsLinearLayout;
vboxl->setOrientation(Qt::Vertical);
vboxl
->addItem
(scene
->addWidget
(new QPushButton("buttonl")));
QGraphicsWidget *form = new QGraphicsWidget;
form->setLayout(vboxl);
scene->addItem(form);
// right side
right->setLayout(vboxr);
//
hbox->addWidget(view);
hbox->addWidget(right);
ui.centralWidget->setLayout(hbox);
}
GraphicWidgetTest::GraphicWidgetTest(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
// left side
QGraphicsView *view = new QGraphicsView(ui.centralWidget);
QGraphicsScene *scene = new QGraphicsScene;
view->setScene(scene);
//scene->setBackgroundBrush(QBrush(QColor(Qt::red)));
QGraphicsLinearLayout *vboxl = new QGraphicsLinearLayout;
vboxl->setOrientation(Qt::Vertical);
vboxl->addItem(scene->addWidget(new QTreeWidget));
vboxl->addItem(scene->addWidget(new QPushButton("buttonl")));
QGraphicsWidget *form = new QGraphicsWidget;
form->setLayout(vboxl);
scene->addItem(form);
// right side
QWidget *right = new QWidget(ui.centralWidget);
QVBoxLayout *vboxr = new QVBoxLayout;
vboxr->addWidget(new QTreeWidget);
vboxr->addWidget(new QPushButton("buttonr"));
right->setLayout(vboxr);
//
QHBoxLayout *hbox = new QHBoxLayout;
hbox->addWidget(view);
hbox->addWidget(right);
ui.centralWidget->setLayout(hbox);
}
To copy to clipboard, switch view to plain text mode
Bookmarks