try using this;
ui->tableWidget->insertRow(row)
count starts from 0 because nothing is there, row 0 is actually the index for the first item. every time you press the add button you will get a new line.
edit: you may also be trying to edit your headers, here is an example of something I am using right now.
void Resolver::on_pushButton_6_clicked()
{
ui->calcResults->clear();
ui->calcResults->setColumnCount(5);
m_TableHeader<<"Bet"<<"Balance"<<"Wager"<<"Payout"<<"Profit"; // is a QStringList
ui->calcResults->setHorizontalHeaderLabels(m_TableHeader);
......
int count = ui->calcResults->rowCount();
ui->calcResults->insertRow(count);
void Resolver::on_pushButton_6_clicked()
{
ui->calcResults->clear();
ui->calcResults->setColumnCount(5);
m_TableHeader<<"Bet"<<"Balance"<<"Wager"<<"Payout"<<"Profit"; // is a QStringList
ui->calcResults->setHorizontalHeaderLabels(m_TableHeader);
......
int count = ui->calcResults->rowCount();
ui->calcResults->insertRow(count);
To copy to clipboard, switch view to plain text mode
you will want to setVerticleHeaderLabels instead
https://doc.qt.io/qt-5/qtablewidget.html
Bookmarks