My aim is to create an array of command link buttons dynamically on clicking a push button in and then display them all inside a vertical layout inside a QscrollArea. I get the data for the buttons from a database. For this I created a slot for the button and wrote the following code inside the slot function.
QCommandLinkButton *slotButtons[10];
for(int i=0; slotQuery.next(); i++)
{
slotButtons[i] = new QCommandLinkButton;
slotButtons[i]->setText(slotQuery.value(0).toString());
slotButtons[i]->setDescription(slotQuery.value(1).toString());
ui->scrollAreaSlots->layout()->addWidget(slotButtons[i]);
ui->scrollAreaSlots->show();
slotButtons[i]->show();
}
This compiles without errors but the buttons are not visible, even after calling show. Could anyone tell me where I'm going wrong?
Update: If i remove all the "[i]"s and comment the loop; basically creating just a single command link button, it works perfectly. But it doesn't work for the loop. Is everything right with my looping?