2 Attachment(s)
Warning when dynamically recreating a QGridLayout
Hello,
The goal of my class MyDialog is to display dynamically 2 or 10 checkboxes using a gridlayout. If the number of checkboxes changes, first
I empty the gridlayout (function clearLayout) and then I insert the desired number of checkboxes.
Unfortunately an annoying warning is displayed (I use qt 5.7 on windows) after the call of adjustSize():
Quote:
setGeometry: Unable to set geometry 22x22+2481+481 on QWidgetWindow/'MyDialogClassWindow'. Resulting geometry: 95x22+2481+481 (frame: 8, 30, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 22x22, maximum size: 16777215x16777215).
Do you understand why there is such a warning ?
Thank you
Code:
#include "mydialog.h"
MyDialog::MyDialog()
{
_value = 2;
setLayout(_layout);
createDisplay();
}
MyDialog::~MyDialog(){}
// remove all the widgets of layout
void MyDialog
::clearLayout(QLayout* layout
) {
if(!layout) return;
{
if (QWidget* widget
= item
->widget
()){ widget->deleteLater();
}
if (QLayout* childLayout
= item
->layout
()) clearLayout(childLayout);
delete item;
}
}
void MyDialog::createDisplay()
{
clearLayout(layout());
_comboBoxType->addItem("2", 2);
_comboBoxType->addItem("10", 10);
if(_value == 2)
{
_comboBoxType->setCurrentIndex(0);
}else
{
_comboBoxType->setCurrentIndex(1);
}
_layout->addWidget(_comboBoxType, 0, 0);
connect(_comboBoxType, SIGNAL(currentIndexChanged(int)), this, SLOT(setValue()));
for(int i=0; i<_value; ++i)
{
_layout->addWidget(w, i+1, 0);
}
adjustSize();
}
void MyDialog::setValue()
{
_value = _comboBoxType->currentData().toInt();
createDisplay();
}
Attachment 12232
Attachment 12233