I have implemented the resizeEvent(). It works good if the size of the window is increased. But it does not decrease the size of QTreeWidget,QPushBotton if the windows size is decreased.
Do i have to resize any other Widget?
GraphicWidgetTest
::GraphicWidgetTest(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
// left side
view->setScene(scene);
left = new QGraphicsWidget();
left->resize(view->size());
QGraphicsProxyWidget *gTree = scene->addWidget(Tree);
QGraphicsProxyWidget *gButton = scene->addWidget(Button);
QGraphicsLinearLayout *vboxl = new QGraphicsLinearLayout;
vboxl->setOrientation(Qt::Vertical);
left->setLayout(vboxl);
vboxw->addWidget(Tree);
vboxw->addWidget(Button);
scene->addItem(left);
//vboxl->addItem(scene->addWidget(left));
vboxl->addItem(gTree);
vboxl->addItem(gButton);
//QGraphicsWidget *form = new QGraphicsWidget;
//form->setLayout(vboxl);
//scene->addItem(form);
// right side
right
= new QWidget(ui.
centralWidget);
right->setLayout(vboxr);
//
hbox->addWidget(view);
hbox->addWidget(right);
ui.centralWidget->setLayout(hbox);
connect(Button,SIGNAL(clicked()),this,SLOT(buttonrClicked()));
}
GraphicWidgetTest::~GraphicWidgetTest()
{
}
void GraphicWidgetTest::buttonrClicked()
{
left->resize(view->size().width()-3,view->size().height()-3);
}
{
left->resize(view->size().width()-3,view->size().height()-3);
}
GraphicWidgetTest::GraphicWidgetTest(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
// left side
view = new QGraphicsView(ui.centralWidget);
scene = new QGraphicsScene;
view->setScene(scene);
scene->setBackgroundBrush(QBrush(QColor(Qt::red)));
left = new QGraphicsWidget();
left->resize(view->size());
QVBoxLayout *vboxw = new QVBoxLayout;
Tree = new QTreeWidget;
Button = new QPushButton("buttonl");
QGraphicsProxyWidget *gTree = scene->addWidget(Tree);
QGraphicsProxyWidget *gButton = scene->addWidget(Button);
QGraphicsLinearLayout *vboxl = new QGraphicsLinearLayout;
vboxl->setOrientation(Qt::Vertical);
left->setLayout(vboxl);
vboxw->addWidget(Tree);
vboxw->addWidget(Button);
scene->addItem(left);
//vboxl->addItem(scene->addWidget(left));
vboxl->addItem(gTree);
vboxl->addItem(gButton);
//QGraphicsWidget *form = new QGraphicsWidget;
//form->setLayout(vboxl);
//scene->addItem(form);
// right side
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);
connect(Button,SIGNAL(clicked()),this,SLOT(buttonrClicked()));
}
GraphicWidgetTest::~GraphicWidgetTest()
{
}
void GraphicWidgetTest::buttonrClicked()
{
left->resize(view->size().width()-3,view->size().height()-3);
}
void GraphicWidgetTest::resizeEvent(QResizeEvent *event)
{
left->resize(view->size().width()-3,view->size().height()-3);
}
To copy to clipboard, switch view to plain text mode
Bookmarks