[Qt-interest] Possible QTableWidget bug appeared in new Qt 4.5.3?

livubuntu at lalescu.ro livubuntu at lalescu.ro
Tue Oct 20 14:06:24 CEST 2009


I compared the sources for Qt 4.5.2, 4.5.3 and 4.6.0-snapshot. It is indeed a
bug, which is shown in 4.5.3 and solved in 4.6.0 (I can show details if you
are interested - see my QtCentre post: http://www.qtcentre.org/forum/f-qt-
programming-2/t-possible-qtablewidget-bug-appeared-in-new-
qt-453-24880.html#post119580 )

My question: I have made a hack to solve this bug with Qt 4.5.3 for my
program. I made something: "if qVersion==QString("4.5.3") then apply hack".

Should I take care of other versions, or only 4.5.3 is affected? What is their
road map - will there be Qt 4.5.4?


Quoting livubuntu at lalescu.ro:

> 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();
> }







More information about the Qt-interest-old mailing list