[Qt-interest] Possible QTableWidget bug appeared in new Qt 4.5.3?
livubuntu at lalescu.ro
livubuntu at lalescu.ro
Mon Oct 19 19:48:03 CEST 2009
Hello!
I have met a problem with latest Qt 4.5.3 (not shown in previous
versions of Qt), problem which exists on Linux and on Windows.
The problem is that if I change data in a QTableWidget using function
table->item(row,col)->setText("new text"), the first row of the table
is not update until I move the mouse over it. For this, run the
attached sample, press the button and see that the first row is not
updated until you move mouse over table.
I have a very small example, attached.
I found that the bug can be avoided if I write
"table->viewport()->update()" after changing of one or more values.
But this may consume unnecessary time?
Maybe you can help me with advice on how to avoid better this bug. It
is important that my software works well with Qt 4.5.3 and with future
versions (I am author of FET - free software for timetabling -
http://lalescu.ro/liviu/fet/
I submitted this possible bug to Qt task tracker, but I have not
received answer until now.
I write below the example (it is the same as the archived attachment):
bug.h:
#include <QApplication>
#include <QtGui>
class Dialog: public QDialog
{
Q_OBJECT
public:
QVBoxLayout* layout;
QTableWidget* table;
QPushButton* pb;
Dialog();
~Dialog();
public slots:
void pbClicked();
};
bug.cpp:
#include "bug.h"
#include <QApplication>
#include <QtGui>
Dialog::Dialog()
{
layout=new QVBoxLayout(this);
table=new QTableWidget();
pb=new QPushButton("Press me");
layout->addWidget(table);
layout->addWidget(pb);
connect(pb, SIGNAL(clicked()), this, SLOT(pbClicked()));
table->setRowCount(5);
table->setColumnCount(5);
for(int i=0; i<5; i++)
for(int j=0; j<5; j++){
QTableWidgetItem* item=new QTableWidgetItem();
item->setText("initial");
table->setItem(i, j, item);
}
table->resizeRowsToContents();
}
Dialog::~Dialog()
{
}
void Dialog::pbClicked()
{
for(int i=0; i<5; i++)
for(int j=0; j<5; j++)
table->item(i,j)->setText(tr("Cell %1,%2 modified").arg(i).arg(j));
}
int main(int argc, char** argv)
{
QApplication app(argc, argv);
Dialog dialog;
dialog.show();
return app.exec();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t-bug-qt.tar.gz
Type: application/x-gzip
Size: 860 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091019/fd75000f/attachment.gz
More information about the Qt-interest-old
mailing list