我在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()));
}
}
当我试图调整大小时,所有布局都会消失。