[Qt-interest] QTableWidget and QTableWidgetItem

Georg Grabler ggrabler at gmail.com
Thu Jan 22 01:36:34 CET 2009


Hello,


I've a strange problem with QTableWidget, inserting Items.

A short outline of my code is below, what exactly isn't working.

I created a form, with a QTableWidget called messageView.

Now, I used quite exactly the code of the documentation, because I've been
experiencing problems.

What I think is strange: I'm never deleting the QTableWidgetItems which was
inserted. But actually, only the last line contains 3 columns, all others
just have the first column filled. Strange, isn't it?

Now, if I don't insert any QTableWidgetItem into setItem(i, 0, newItem),
column 2 and 3 are filled (1 is ofc empty).

What part of the documentation did I miss? What does QTableWidget expect in
[i][0]? What does it do on settingthe first column of a row?
I'm using QT 4.5 beta2 for those tests.

Kind regards,
Georg

---------------------

void MyTest::setupMessageView() {
  // Insert header
  QStringList headerList;

  headerList << "TestCol1";
  headerList << "TestCol2";
  headerList << "TestCol3";

  messageView->setColumnCount(headerList.size());
  messageView->setHorizontalHeaderLabels(headerList);

  // insert rows

  for (int row=0; row<21; row++) {
  messageView->insertRow(row);

  for (int column = 0; column<3; column++) {
  QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(pow(row,
column+1)));
  messageView->setItem(row, column, newItem);
  }
  }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090122/a6050b19/attachment.html 


More information about the Qt-interest-old mailing list