robgeek
13th December 2015, 22:09
Hello!
I have a QTableWidget in my program and i would like the scrollbar stay on the bottom of it at the first time that she load the data. To do that i tried as follows:
DataLoader::DataLoader(QWidget *parent) : QDialog( parent ), ui(new Ui::DataLoader) {
ui->setupUi( this );
//...
showHistTable(ui->tableHist, matrix);
//...
}
//...
void showHistTable(QTableWidget *table, Historic historic) {
// Clear all data.
for(int i = 0; i < historic.size; i++)
table->removeRow( 0 );
for(int i = 0; i < historic.size; i++) {
table->insertRow( i );
for(int j = 0; j < historic.win; j++) {
QTableWidgetItem *val = setNumberCell( historic.historic[i][j] );
table->setItem(i, j, val);
}
}
// Scrollbar in the bottom.
table->verticalScrollBar( )->setValue( table->verticalScrollBar( )->maximum( ) );
}
Why this code is not working?
How can i fix it?
I have a QTableWidget in my program and i would like the scrollbar stay on the bottom of it at the first time that she load the data. To do that i tried as follows:
DataLoader::DataLoader(QWidget *parent) : QDialog( parent ), ui(new Ui::DataLoader) {
ui->setupUi( this );
//...
showHistTable(ui->tableHist, matrix);
//...
}
//...
void showHistTable(QTableWidget *table, Historic historic) {
// Clear all data.
for(int i = 0; i < historic.size; i++)
table->removeRow( 0 );
for(int i = 0; i < historic.size; i++) {
table->insertRow( i );
for(int j = 0; j < historic.win; j++) {
QTableWidgetItem *val = setNumberCell( historic.historic[i][j] );
table->setItem(i, j, val);
}
}
// Scrollbar in the bottom.
table->verticalScrollBar( )->setValue( table->verticalScrollBar( )->maximum( ) );
}
Why this code is not working?
How can i fix it?