Hello!
I am the author of a free software for timetabling, http://lalescu.ro/liviu/fet/
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 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>
{
Q_OBJECT
public:
Dialog();
~Dialog();
public slots:
void pbClicked();
};
#include <QApplication>
#include <QtGui>
class Dialog: public QDialog
{
Q_OBJECT
public:
QVBoxLayout* layout;
QTableWidget* table;
QPushButton* pb;
Dialog();
~Dialog();
public slots:
void pbClicked();
};
To copy to clipboard, switch view to plain text mode
bug.cpp:
#include "bug.h"
#include <QApplication>
#include <QtGui>
Dialog::Dialog()
{
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++){
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)
{
Dialog dialog;
dialog.show();
return app.exec();
}
#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();
}
To copy to clipboard, switch view to plain text mode
Bookmarks