PDA

View Full Version : How to make a user not resize a window.



marcos.miranda
20th September 2017, 18:10
Hello everyone.

I'm not getting a QWidget-based window to stay fixed, without the user resizing it.
Just to level the information I'm using Linux Debian 8.5 64Bits, Qt 5.7.0 (GCC 4.9.1 20140922 (Red Hat 4.9.1-10), 64 bit) and Qt Creator 4.0.2.




frmMainWindow::frmMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::frmMainWindow)
{
ui->setupUi(this);
this->setWindowTitle("Sistema Em Qt");
this->ui->mainToolBar->setVisible(false);
this->setCentralWidget(ui->mdiAreaMain);
this->showMaximized();
}

void frmMainWindow::on_actConfig_do_Sistema_triggered()
{
frmConfigSistema *frmConfigSistemaObj = new frmConfigSistema;
frmConfigSistemaObj->setFixedSize(740,360);
frmConfigSistemaObj->setWindowTitle("Configurações do Sistema");
ui->mdiAreaMain->addSubWindow(frmConfigSistemaObj);
frmConfigSistemaObj->show();
}




I have tried in several ways like:

1) - Not to display the Minimize and Maximize buttons.



Qt::WindowFlags flags ;
flags |= Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint
this->setWindowFlags(flags);


2) - Fix the size by the code.



frmConfigSistemaObj->setFixedSize(740,360);
frmConfigSistemaObj-> setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixe d);


3) - Fix the size by Qt Creator Property Editor according to PrntScr "Fig - Redimensionamento_1.jpg".



The closest I got was with the code below, but two windows pop up at once. "Fig - Redimensionamento_2.jpg".



frmConfigSistema *frmConfigSistemaObj = new frmConfigSistema;
frmConfigSistemaObj->setFixedSize(740,360);
frmConfigSistemaObj->setWindowTitle("Configurações do Sistema");
ui->mdiAreaMain->addSubWindow(frmConfigSistemaObj);
Qt::WindowFlags flags = 0;
frmConfigSistemaObj->setWindowFlags(flags);
frmConfigSistemaObj->setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
frmConfigSistemaObj->show();


Does anyone have any examples that I can follow, or an explanation of what is happening?

Thanks.

ado130
20th September 2017, 20:53
Try to set width and height in minimumSize and maximumSize to same size as in Geometry tab.

marcos.miranda
20th September 2017, 21:23
Hello, ado130.

I had already done this, and nothing happened.
The window continues to be resized.

Thanks.