0
votes

I have the following problem.I have a QmainWindow which sets main layout and a widget added to that Layout. When I resize the widget the QmainWindows remains the same size.

Here is the setup: In the QmainWindow on init:

this->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

m_mainLayout = new QVBoxLayout();
m_mainLayout->setAlignment(Qt::AlignHCenter);

m_centralWidget = new QWidget();

m_centralWidget->setLayout(m_mainLayout);
setCentralWidget(m_centralWidget);

this->setMinimumSize(800,600);

m_mainLayout->addWidget(m_GLWidget);

Then,at some point m_GLWidget signals it needs to be resized.QmainWindow catches the signal and

reized the m_GLWidget:

 void MainWindow::ResizeViewportSlot(int w,int h){

  m_GLWidget->setFixedSize(w,h);

  m_GLWidget->updateGeometry();

  this->updateGeometry();


}
1
Cause you set the minimum size on QMainWindow?Tay2510
So how do I set some default size to the main window without using setMinimumSize() ,which I already see is the cause of the problem?Michael IV
You may use resize(800, 600) in the constructor instead of setMinimumSize which creates limits.Tay2510
Great!!!!!That's what I was after!You could put it as an answer.Michael IV

1 Answers

2
votes

You may use resize(800, 600) in the constructor instead of setMinimumSize which creates limits.

By the way, although it's a common function, resize is inherited from QWidget and many people (me included) can't find it in the document page of QMainWindow.

I think you are just one of the victims.

[Edit]

Thanks to lpapp's comment:

"Usually one can click on the List of all members, including inherited members link to get to all the members of a class."