You don't need variables with variable names:
// how to create and set a cell widget in each cell:
for (int row = 0; row < ui.tableWidget->rowCount(); ++row)
{
for (int col = 0; col < ui.tableWidget->columnCount(); ++col)
{
toolsContacts* contactListTool = new toolsContacts(ui.tableWidget);
ui.tableWidget->setCellWidget(row, col, contactListTool);
}
}
// how to access a cell widget in particular cell:
toolsContacts* contactListTool = dynamic_cast<toolsContacts*>(ui.tableWidget->cellWidget(2, 3)); // row, col
if (contactListTool)
{
// the cell contains a cell widget and it's of type toolsContacts
contactListTool->doSomething();
}
// how to create and set a cell widget in each cell:
for (int row = 0; row < ui.tableWidget->rowCount(); ++row)
{
for (int col = 0; col < ui.tableWidget->columnCount(); ++col)
{
toolsContacts* contactListTool = new toolsContacts(ui.tableWidget);
ui.tableWidget->setCellWidget(row, col, contactListTool);
}
}
// how to access a cell widget in particular cell:
toolsContacts* contactListTool = dynamic_cast<toolsContacts*>(ui.tableWidget->cellWidget(2, 3)); // row, col
if (contactListTool)
{
// the cell contains a cell widget and it's of type toolsContacts
contactListTool->doSomething();
}
To copy to clipboard, switch view to plain text mode
Bookmarks