可尝试以下方法:
1
void showEvent(QShowEvent *event)
{
this->setAttribute(Qt::WA_Mapped);
QWidget::showEvent(event);
}
2、界面控件切换前调用:
show();
qApp->processEvents();
3、update()
4、adjustSize();
5、resize(size());