如何借助 Qpushbutton 更改 QDialog 框的宽度

How to change the width of a QDialog box with the help of Qpushbutton

我有一个名为“验证对话框”的 QDialog 框和一个名为“刷新宽度”的对话框上的 QPush 按钮,当我单击此按钮时,QDialog 框的宽度必须从 1000 更改为 500,

通过阅读一些文档,我知道我可能可以使用 setFixedWidth(int w) 函数,并尝试使用它但遇到一些语法问题。

但我可以将它用于 QPushbutton 和 QDialog 上的其他小部件,但是如何使用 setFixedWidth 在单击按钮时更改主 QDialog 的宽度??

@Mr_Workalot 这是非常基本的,所以第一次我认为没有必要显示源代码。但为了避免混淆或误解,下面是代码供您参考。

#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    resize(1000, 400);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_pushButton_clicked()
{
    setFixedWidth(500);
}