But i used "new" and still not working!
Bellow, the entire code.
{
ui->setupUi( this );
ui->tableWidget->setColumnCount( 21 );
QHeaderView *header
= ui
->tableWidget
->horizontalHeader
( );
for(int i = 0; i < COLS; i++)
colsnames <<
QString::number( (i
+ 1) );
ui->tableWidget->setHorizontalHeaderLabels( colsnames );
for(int i = 0; i < LINES; i++)
{
for(int j = 0; j < COLS; j++)
{
ui->tableWidget->setItem(i, j, val);
}
}
}
Test::Test(QWidget *parent) : QDialog( parent ), ui(new Ui::Test)
{
ui->setupUi( this );
ui->tableWidget->setColumnCount( 21 );
QHeaderView *header = ui->tableWidget->horizontalHeader( );
header->resizeSections(QHeaderView::Stretch);
QStringList colsnames("#");
for(int i = 0; i < COLS; i++)
colsnames << QString::number( (i + 1) );
ui->tableWidget->setHorizontalHeaderLabels( colsnames );
for(int i = 0; i < LINES; i++)
{
for(int j = 0; j < COLS; j++)
{
QTableWidgetItem *val = new QTableWidgetItem( QString::number( 123 ) );
ui->tableWidget->setItem(i, j, val);
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks