Solved Still can resize the Window after setSizePolicy to fixed
-
Hi, here's the constructor of my MainWindow class. I set the window size policy to fixed, and updateGeometry, but still can resize the window. Why it can't work? Maybe I used it in a wrong way?
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); this->updateGeometry(); }
-
Size policy is a layout attribute. So it only takes effect in layouts.
It will never have any effect on a window.
If you don't want your window to be resized, you should usesetFixedSize
. -
@Bonnie Thank you ~