QTableWidget header text
-
Hi everyone,
My problem is simple but i am new at qt. So, my problem is that i have a QTableWidget and i have to set its header text.
i have 7 columns and by default header texts are 1,2,3,...,7 .How can i change it's text?
Thanks in advance.
-
Have a look at the "qtablewidget docs":http://developer.qt.nokia.com/doc/qt-4.8/qtablewidget.html#setHorizontalHeaderLabels.
-
[quote author="Eddy" date="1325661070"]Have a look at the "qtablewidget docs":http://developer.qt.nokia.com/doc/qt-4.8/qtablewidget.html#setHorizontalHeaderLabels.[/quote]
Thanks. i tried this,
@QTableWidgetItem *header1 = new QTableWidgetItem();
header1->setText("Switch "ON" to Load");
tableWidget->setHorizontalHeaderItem(0,header1);QTableWidgetItem *header2 = new QTableWidgetItem(); header2->setText("Parameter No."); tableWidget->setHorizontalHeaderItem(1,header2);
@
It works, i did that for all seven column. but is this a good way?
-
[quote author="joonhwan" date="1325669987"]one liner could do that.
@
tableWiget->setHorizontalHeaderLabels(QStringList() << "Switch.." << "Parameter...");
@[/quote]thanks .