I know it seems a stupid question, but I cannot find how to change QTableWidget header name or text.
Any idea?
Thanks.
Printable View
I know it seems a stupid question, but I cannot find how to change QTableWidget header name or text.
Any idea?
Thanks.
take a look at QTableWidget::setHorizontalHeaderLabels and QTableWidget::setHorizontalHeaderItem (in this case you can use QTableWidgetItem::setText).
Thanks.
ui.tableWidgetTextureLibrary->setHorizontalHeaderItem(0, new QTableWidgetItem("Prueba"));
Worked
But this one
ui.tableWidgetTextureLibrary->horizontalHeaderItem(0)->setText("Whatever");
Doesn't work.
I mena, instead of creating a new QTableWidgetItem, can I edit the current one?
Thanks.
yes, you can. but at first you have to add an item, because if you don't do this your programm will crash if you use this code:
so, if you already created an item like thisCode:
ui.tableWidgetTextureLibrary->horizontalHeaderItem(0)->setText("Whatever");
then in you code you can use horizontalHeaderItem for changing column name, because horizontalHeaderItem will return valid pointer.