Creating a 32x32 "Matrix" of dynamicaly added buttons into a layout!
Solved
General and Desktop
-
what am i doing wrong here? it only creates 1 button :S
const int colCount = 32; const int rowCount = 32; int Index = 1; for (int r = 0; r < rowCount; r++) { for(int c = 0; c < colCount; c++) { QPushButton *button = new QPushButton(this); connect(button, &QPushButton::clicked, [=]() { qDebug() << button->objectName(); }); button->setMinimumSize(16, 16); button->setMaximumSize(16, 16); button->setFixedSize(16, 16); button->setCursor(Qt::PointingHandCursor); button->setObjectName(QString::number(Index)); ui->GRID_IMAGEFOLDER_DISPLAY->setColumnStretch(11, 100); //ui->GRID_IMAGEFOLDER_DISPLAY->setRowStretch(11, 100); ui->GRID_IMAGEFOLDER_DISPLAY->addWidget(button, rowCount, colCount); ++Index; } }
-
Hi,
No it does not create only one button, you set all your buttons in the same cell of your grid.