Im a student programmer and Im using Qt to build a GUI for one of my company’s product. Essentially this GUI is going to read certain files and feed the data into a table for users to edit. I know how to construct the QTableWidget statically. In which case i used the following:
for(int x=0; x < ui->tableWidgetInjectionLocations->rowCount(); x++)
{
for(int y=0; y < ui->tableWidgetInjectionLocations->columnCount(); y++)
{
ui->tableWidgetInjectionLocations->setItem(x,y, qTableWidgetItemInjection);
}
}
The problem is this way creates a static or fixed number of cells I would instead like the cells to be constructed based on the user interaction. Perhaps when a user fills any cells in the last line to populate a new one or when the user scrolls down… I digress the thing is I haven’t been able to find any documentation on how to approach this in Qt Documentation. Maybe its writers block or I’m missing something obvious but any help would be awesome. Thanks for reading and thanks for any help in advance.
To add a row, just do a
QAbstractItemModel::insertRowon yourQTableWidget::model().The
QTableWidgetwill adjust itself automatically.i.e.
to add a row after the last one.
There are tons of way to trigger the append, you’d have to be more precise on what you want…