robgeek
18th April 2015, 00:23
Hi!
I'm using a spinbox(in data.cpp) to show some data in a table, but everytime i change the spinbox value, the table shows me the new values with the old ones. My table doens't erase the old data. I don't want that, i want just the new data! How can i do that?
// data.h
class Data : public QDialog
{
Q_OBJECT
public:
Table confTable;
QList<Number> ranking;
//...
// data.cpp
void Data::on_spinRkgLM_valueChanged(int arg1)
{
ranking = hs->rankingNumbers(hs, arg1);
confTable.showRkgTable(ui->tableWidget, ranking );
}
// "Table" is a class i use only to put all configurations(omitted here) and showing codes.
void Table::showRkgTable(QTableWidget *table, QList<Number> numbers)
{
int size = numbers.size( );
for(int i = 0; i < size; i++)
{
table->insertRow( i );
QTableWidgetItem *val = new QTableWidgetItem( QString::number( numbers[ i ].val ) );
QTableWidgetItem *acum = new QTableWidgetItem( QString::number( numbers[ i ].acum) );
table->setItem(i, 0, val);
table->setItem(i, 1, acum);
}
}
I'm using a spinbox(in data.cpp) to show some data in a table, but everytime i change the spinbox value, the table shows me the new values with the old ones. My table doens't erase the old data. I don't want that, i want just the new data! How can i do that?
// data.h
class Data : public QDialog
{
Q_OBJECT
public:
Table confTable;
QList<Number> ranking;
//...
// data.cpp
void Data::on_spinRkgLM_valueChanged(int arg1)
{
ranking = hs->rankingNumbers(hs, arg1);
confTable.showRkgTable(ui->tableWidget, ranking );
}
// "Table" is a class i use only to put all configurations(omitted here) and showing codes.
void Table::showRkgTable(QTableWidget *table, QList<Number> numbers)
{
int size = numbers.size( );
for(int i = 0; i < size; i++)
{
table->insertRow( i );
QTableWidgetItem *val = new QTableWidgetItem( QString::number( numbers[ i ].val ) );
QTableWidgetItem *acum = new QTableWidgetItem( QString::number( numbers[ i ].acum) );
table->setItem(i, 0, val);
table->setItem(i, 1, acum);
}
}