[Qt-interest] why terminated () or finsished () signals are not emitted when run() is finished.

Sean Harmer sean.harmer at maps-technology.com
Thu Sep 3 11:03:53 CEST 2009


On Thursday 03 Sep 2009 09:39:34 Santhosh Y wrote:
> Let us say I have a table widget with huge no of rows. Since this is a
> time consuming operation for creating and updating,  GUI freezes and
> user may think that application has crashed and he may kill it.
> What I want to achieve is that, When any GUI updation is taking huge
> time it gives a busy cursor by default  instead of that, I want to show
> some timer kind of stuff / dialog  which indicates some updation is
> going on.
>
> This way we can still allow the main thread to freeze but the timer will
> show the status. Once GUI thread is ready we may close the timer dialog.
>
> How can I achieve this?
You did not read my previous email properly. Here is the relevant part again 
that does not use threads:

"If you insist on using an item based approach then break your creation up 
into smaller chunks and *do it in the main thread*. 

If you call qApp->processEvents() at regular intervals it will keep your GUI 
responsive."

Something like this:

QTableWidgetItem* item = 0;
for (int i=0; i<40000; i++) 
{
        for (int j=0; j<4; j++) 
	{
		item = new QTableWidgetItem(QString("Item %1, %2").arg(i).arg(j)), i, j);
		table->setItem( i, j, item );
        }

	// Let the GUI remain responsive. Allow it to update every 100 rows
	if ( i % 100 == 0 )
	{
		qApp->processEvents();
	}
}

This Qt Quarterly article is also worth a read on this topic:

http://doc.trolltech.com/qq/qq27-responsive-guis.html

Good luck,

Sean



More information about the Qt-interest-old mailing list