QTableWidget header text
-
wrote on 4 Jan 2012, 06:57 last edited by
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.
-
wrote on 4 Jan 2012, 07:11 last edited by
Have a look at the "qtablewidget docs":http://developer.qt.nokia.com/doc/qt-4.8/qtablewidget.html#setHorizontalHeaderLabels.
-
wrote on 4 Jan 2012, 07:43 last edited by
[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?
-
wrote on 4 Jan 2012, 09:39 last edited by
one liner could do that.
@
tableWiget->setHorizontalHeaderLabels(QStringList() << "Switch.." << "Parameter...");
@ -
wrote on 4 Jan 2012, 10:11 last edited by
[quote author="joonhwan" date="1325669987"]one liner could do that.
@
tableWiget->setHorizontalHeaderLabels(QStringList() << "Switch.." << "Parameter...");
@[/quote]thanks .
-
wrote on 17 Jun 2014, 13:03 last edited by
thank you very much ...