[Qt-interest] Updating the TableWidgetItem slows down the operation significantly.

Malyushytsky, Alex alex at wai.com
Fri Feb 26 22:25:32 CET 2010


I see nothing wrong, but can make some suggestions.
First the way you create string is too complex.
There is no need to construct QString few times ( on arg() is needed)

tableWidget->item(index, 2)->setText( QString::number( value ) );
setText is equal setData(Qt::DisplayRole, v) , just looks shorter.

Don't expect the above to improve speed noticeably, but you may try.

Are you sure you have no slots connected to the signals like QTableWidget::cellChanged ?
In other words is there any additional code executed when item data is changed?

Alex






-----Original Message-----
From: Yong Zhang [mailto:yzhang.qt at gmail.com]
Sent: Friday, February 26, 2010 6:59 AM
To: Malyushytsky, Alex; qt-interest at trolltech.com
Subject: Re: Updating the TableWidgetItem slows down the operation significantly.

Hi Alex,

Thanks. I am using Windows XP professional, Qt v4.6, 3GB memory and Intel Core 2 Duo 2.4GHz. Here are the sample codes:

value = getPositions();
QString valueString = QString("%1").arg(QString::number(double( value )));
tableWidget->item(index, 2)->setData(Qt::DisplayRole, valueString);

value is updated when user moves mouse and the valueString is also updated to refresh the table. This slows down the operation. If valueString does not update then it works very smoothly. Can you tell me what is wrong with the codes?

Thank you very much,

Yong


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

Message: 1
Date: Thu, 25 Feb 2010 16:54:58 -0800
From: "Malyushytsky, Alex"<alex at wai.com>
Subject: Re: [Qt-interest] Updating the TableWidgetItem slows down the
        operation       significantly.
To:"qt-interest at trolltech.com"  <qt-interest at trolltech.com>
Message-ID:<F8145CF983B4DB42855E9BB7F5BE8FCC2F105DA1 at camail2>
Content-Type: text/plain; charset="us-ascii"

It might depend on the system, qt version installed, hardware, etc.
I do similar things actually even more, cause I also map to the GraphicsScene coordinate and it works without any visible delay.

Alex



-----Original Message-----
From:qt-interest-bounces at trolltech.com  [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Yong Zhang
Sent: Thursday, February 25, 2010 4:36 PM
To:qt-interest at trolltech.com
Subject: [Qt-interest] Updating the TableWidgetItem slows down the operation significantly.

Hi All,

I use a QTableWidget to display the current location values (x, y) of
the mouse on the screen. I display the mouse location using a hand image
on the screen. When the mouse moves, the mouse image is updated on the
screen to indicate the new location. My goal is to also update the
location values (x, y) in the QTableWidget as two QTableWidgetItems. The
system works well, however, I found that it significantly slows down the
operations, that is, the update of the mouse image on the screen is very
slow and the mouse movements are not smooth. When I do not update the
location values in the QTableWidget, I can move the mouse around very
smoothly and the mouse image is also updated very smoothly. My question
is, is there anyway to make it fast and smooth enough to update the
information in the QTableWidget?

Thank you very much,

Yong



---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list