改变位置QVBoxLayout Qt

时间:2017-03-01 10:45:50

标签: c++ qt qt4 qt5

我在QMainWindow上有QGraphicsView和QVBoxLayout。我想更改QVBoxLayout位置,当用户想要调整窗口大小时,QGraphicsView必须保留。

尝试使用QMainWindow :: resizeEvent:

 void Interface::resizeEvent(QResizeEvent *event)
    {
        QMainWindow::resizeEvent(event);
        if (this)
        {
            QRect temp(ui.interfaceLayout->geometry());
            ui.interfaceLayout->setGeometry(QRect(event->size().width() - temp.width(), 
                                temp.top(), temp.width(), temp.height()));
        }
    }

当我试图调整大小时,所有布局都会消失。

0 个答案:

没有答案