[Qt-interest] please help me with this problem

Scott Aron Bloom Scott.Bloom at sabgroup.com
Tue Dec 8 04:23:17 CET 2009


The problem is you are trying to change the GUI directly, from a non-gui thread...

Make sure your GUI's event loop, is still active, and not in blocked state.. Without seeing how you have the threads connected, there is no way to tell what the problem is.

Scott

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Yifei Li
Sent: Monday, December 07, 2009 6:40 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] please help me with this problem

I use a variable to keep track of the current message to be displayed.
every time the signal displayMessage is emitted to a slot, that slot calls QGraphicsScene::update()

but I never see the first two messages show up

Yifei
----- Original Message -----
From: "程梁" <chengliang.soft at gmail.com>
To: qt-interest at trolltech.com
Sent: Monday, December 7, 2009 7:44:46 PM GMT -05:00 US/Canada Eastern
Subject: Re: [Qt-interest] please help me with this problem


I think it is because it is really paint but the later one draws over it. 
That is the scene refresh by the new message. 


2009/12/8 Yifei Li < yifli at mtu.edu > 


Hi folks, 

In my thread's run() method, signal displayMessage(QString) is emitted and the signal is connected to a slot setMessage(QString) in a QGraphicsScene object (using direct connection) 

// run method looks like this: 
void run() 
{ 
sleep(2); 
emit displayMessage("hello 1"); 
sleep(2); 
emit displayMessage("hello 2"); 
sleep(2); 
emit displayMessage("hello 3"); 
} 

// Here is what setMessage(QString) looks like: 
void setMessage(QString msg) 
{ 
m_message = msg; // save the message 
update(); 
} 

The message is then displayed in drawForegound method 


However, my problem is 'hello1' and 'hello2' don't show up at all, only 'hello3' does. 

My guess is that update() queues the paint event and several paint events are merged into one due to optimization, so what should I do make those three messages displayed one after another? 

Thanks 

Yifei 
_______________________________________________ 
Qt-interest mailing list 
Qt-interest at trolltech.com 
http://lists.trolltech.com/mailman/listinfo/qt-interest 



-- 
Cheng Liang 
from: chengliang.soft at gmail.com 

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list