Normal QTablewidget is as follows:
a b
1 data data
2 data data
3 data data
I want to remove the first column that shows row numbers. My table should look like this:
a b
data data
data data
data data
I can not find the way to do this. Let me know if there is a way to add items more easily. That 's how I implemented my table:
QString a[5];
a[0]="ddd";
QTableWidgetItem *item1 = new QTableWidgetItem(a[0]);
ui->tableWidget->setItem(0,0,item1 );
There are two views in QTable
the vertical and the horizontal header, they are defined in QTableView
, as any widget you can hide them so it can be done as below :
ui->tableWidget->verticalHeader()->setVisible(false); // Get Vertical header and hide it
You can have vertical header in easy way as one line code,
ui->tableWidget->setHorizontalHeaderLabels(QString("HEADER 1;HEADER 2;HEADER 3;HEADER 4").split(";"));
For setting the data in Table you can use QString Array
which contains data using for
loop you can store the data in table, but you need to take care about indexing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With