Don't call QGridLayout::itemAtPosition.
Like this,
1 2 3 4 5 6 7 8 9 10 11 12 | for (int i = 0; i < grid_layout->count(); i++) { QLayoutItem* item = grid_layout->itemAt(i); if (item->widget() == widget_wanted) { int row, column, row_span, column_span; grid_layout->getItemPosition(i, &row, &column, &row_span, &column_span); // grid_layout->addWidget(frame, row, column); } } |