Try moving the scroll bar adjustment to the showEvent() method.
Sorry, but i don't understand what do you mean with that. I don't have this method implemented.
My code with one more method i implemented:
DataLoader
::DataLoader(QWidget *parent
) : QDialog( parent
), ui
(new Ui
::DataLoader) { ui->setupUi( this );
//...
configHistTable(ui->TableHist, matrix->length);
showHistTable(ui->tableHist, matrix);
//...
}
//...
int width = 100;
for(int i = 0; i < (cols + 1); i++)
table->setColumnWidth(i, width);
}
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++) {
table->setItem(i, j, val);
}
}
// Scrollbar in the bottom.
table->verticalScrollBar( )->setValue( table->verticalScrollBar( )->maximum( ) );
}
DataLoader::DataLoader(QWidget *parent) : QDialog( parent ), ui(new Ui::DataLoader) {
ui->setupUi( this );
//...
configHistTable(ui->TableHist, matrix->length);
showHistTable(ui->tableHist, matrix);
//...
}
//...
void configHistTable(QTableWidget *table, int cols) {
int width = 100;
for(int i = 0; i < (cols + 1); i++)
table->setColumnWidth(i, width);
}
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( ) );
}
To copy to clipboard, switch view to plain text mode
Bookmarks