[Qt-interest] Table header text

Malyushytsky, Alex alex at wai.com
Tue May 19 03:20:42 CEST 2009


Try use new to a allocate QTableWidgetItem(), so it is not destroyed when goes out of scope,
something like this:

QTableWidgetItem* column = new QTableWidgetItem();
column->setText("Header");
tableWidget.setHorizontalHeaderItem(0, column);

Regards,
    Alex

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Anatoly Burakov
Sent: Monday, May 18, 2009 1:22 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Table header text

Hello everyone!

I'm kinda new to QT4 (and not at all an experienced programmer) and i
got a question.

I am writing a program with MDI. An MDI window gets open after a menubar
item was clicked. The QMdiSubWindow has a QTableWidget as a central
widget. Basically, i am trying to change column headers' text. It works
fine if i do like this:

QStringList headerList;
headerList << "Header";

tableWidget.setHorizontalHeaderLabels(headerList);


but if i create each column header individually - it does not change
header labels:

tableWidget.setColumnCount(1);

tableWidget.setRowCount(0);

QTableWidgetItem column;

column.setText("Header");

tableWidget.setHorizontalHeaderItem(0, &column);


I would be grateful for any help. I use Qt Creator 1.1.0 (QT version 4.5.1).

Thank you,
Anatoly
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list