在QWidget窗口中添加相关事件resizeEvent()函数并编写相关功能代码:
void Widget::resizeEvent(QResizeEvent *event)
{
QSize sz=ui->plainTextEdit->size();
ui->plainTextEdit->move(5,5);
ui->pabpic->move(5,sz.height()+5);
ui->plainTextEdit->resize(this->width()-10,sz.height());
ui->pabpic->resize(this->width()-10,this->height()-sz.height()-20);
event->accept();
}
运行效果如下: