Grid issue
« on: 27 July 2017, 16:38:12 »
When i add some buttons to my grid widget, i use the center align (default).
However if i use removeAllWidgets before i add my buttons to grid the alignment is getting top-left.

I use the 0.7.4

Code: [Select]

int index = 0;
for (unsigned int row = 0; row < 2; ++row)
for (unsigned int col = 0; col < 2; ++col) {
pGrid->addWidget(pGridButtons[index++], row, col);

One solution is to use this code insted of "removeAllWidgets()"
Code: [Select]
auto& widgets = pGrid->getWidgets();
for (int i = 0; i < widgets.size(); i++)
« Last Edit: 27 July 2017, 16:48:23 by billarhos »



  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Grid issue
« Reply #1 on: 27 July 2017, 18:17:40 »
removeAllWidgets apparently calls setSize(0,0) so another workaround would be to set the size again after removing the widget.
I tried to figure out why the code is there to determine if it is ok to just remove it and it turns out that setting the size to (0,0) is something that was added early in 2013, when the size of the grid still had a different meaning. I have removed the setSize call now, you can download the source code of the latest version on github.