lalesculiviu
19th October 2009, 13:32
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>
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();
}
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>
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();
}