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():
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


Qt Code:
  1. #include "mydialog.h"
  2.  
  3. MyDialog::MyDialog()
  4. {
  5. _value = 2;
  6. _layout = new QGridLayout;
  7. setLayout(_layout);
  8. createDisplay();
  9. }
  10.  
  11. MyDialog::~MyDialog(){}
  12.  
  13. // remove all the widgets of layout
  14. void MyDialog::clearLayout(QLayout* layout)
  15. {
  16. if(!layout) return;
  17. while (QLayoutItem* item = layout->takeAt(0))
  18. {
  19. if (QWidget* widget = item->widget()){
  20. widget->deleteLater();
  21. }
  22.  
  23. if (QLayout* childLayout = item->layout())
  24. clearLayout(childLayout);
  25. delete item;
  26. }
  27. }
  28.  
  29. void MyDialog::createDisplay()
  30. {
  31. clearLayout(layout());
  32.  
  33. _comboBoxType = new QComboBox();
  34. _comboBoxType->addItem("2", 2);
  35. _comboBoxType->addItem("10", 10);
  36. if(_value == 2)
  37. {
  38. _comboBoxType->setCurrentIndex(0);
  39. }else
  40. {
  41. _comboBoxType->setCurrentIndex(1);
  42. }
  43. _layout->addWidget(_comboBoxType, 0, 0);
  44. connect(_comboBoxType, SIGNAL(currentIndexChanged(int)), this, SLOT(setValue()));
  45.  
  46. for(int i=0; i<_value; ++i)
  47. {
  48. QCheckBox *w = new QCheckBox("Value :", this);
  49. _layout->addWidget(w, i+1, 0);
  50. }
  51. adjustSize();
  52. }
  53.  
  54. void MyDialog::setValue()
  55. {
  56. _value = _comboBoxType->currentData().toInt();
  57. createDisplay();
  58. }
To copy to clipboard, switch view to plain text mode 

mydialog.cpp
mydialog.h