[Qt-interest] Fwd: Subclassed QTableWidget table does not show column header labels after setting them.
David Narvaez
david.e.narvaez at gmail.com
Tue Nov 10 21:38:39 CET 2009
---------- Forwarded message ----------
From: David Narvaez <david.e.narvaez at gmail.com>
Date: Tue, Nov 10, 2009 at 3:38 PM
Subject: Re: [Qt-interest] Subclassed QTableWidget table does not show
column header labels after setting them.
To: Sorin Lazarescu <Sorin.Lazarescu at jdsu.com>
Unconfirmed. I compiled and ran the code (Qt 4.2/Linux) and headers are
correctly displayed.
*David E. Narváez*
Member of the Institute of Electrical and Electronics Engineers
Member of the Computer Society of the IEEE
Member of the Association for Computer Machinery
Member of the Society for Industrial and Applied Mathematics
On Tue, Nov 10, 2009 at 1:42 PM, Sorin Lazarescu
<Sorin.Lazarescu at jdsu.com>wrote:
> Hi everybody
>
>
>
> I wonder what could be wrong with my subclassed QTableWidget where after I
> set custom column labels but still the table column header labels keep
> showing 1, 2, 3,4,5,6,7.
>
>
>
> class XmlTable : public QTableWidget
>
> {
>
> Q_OBJECT
>
> public:
>
> XmlTable(QWidget *parent = 0);
>
> }
>
>
>
> MainWindow::MainWindow()
>
> {
>
> xmlTable = new XmlTable(this);
>
>
>
> //fill 7 column header labels
>
> QStringList labels;
>
> labels << tr("Zone") << tr("InnerDiameter") <<
> tr("OuterDiameter") << tr("ResultDefects") << tr("CountDefects") <<
> tr("AreaDefects") << tr("ResultScratches") ;
>
> qDebug() << "column labels size is: " << labels.size() <<
> endl;
>
>
>
> //set number of rows and columns
>
> xmlTable->setRowCount(0);
>
> xmlTable->setColumnCount(labels.size());
>
> //set column header labels here
>
> xmlTable->setHorizontalHeaderLabels(labels);
>
>
>
> //CHECK column headers below show that column headers has
> been changed to “Zone”, “InnerDiameter”, “OuterDiameter” ,…
>
> for ( int i = 0; i < labels.size(); i++ )
>
> {
>
> QTableWidgetItem *item =
> xmlTable->horizontalHeaderItem(i);
>
> QString text = item->text();
>
> qDebug() << "Header Item Text: " << text <<
> endl;
>
> }
>
> setCentralWidget(xmlTable);
>
> }
>
>
>
> int main(int argc, char *argv[])
>
> {
>
> QApplication app(argc, argv);
>
> MainWindow mainWin;
>
> mainWin.show();
>
> return app.exec();
>
> }
>
>
>
> I created a custom QTableWidget in a MainWindow then the use QApplication
> to display it.
>
> I could see that my column headers item contains the labels as they have
> been set trough setHorizontalHeaderLabels() function but XmlTable table
> display shows always column headers as 1,2,3, 4,5,6,7 instead of “Zone”,
> “InnerDiameter”, “OuterDiameter”
>
>
>
>
>
> Any idea why I could not see the new column headers labels?
>
>
>
> Thanks
>
>
>
> Sorin
>
>
>
>
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091110/067730b2/attachment.html
More information about the Qt-interest-old
mailing list