Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Problem with QT / Threads / Signals / Slots

Reply
Thread Tools

Problem with QT / Threads / Signals / Slots

 
 
Frank Bossy
Guest
Posts: n/a
 
      07-09-2003
Dear group

I don't quite understand the meaning of this paragraph in the qt docu
(http://doc.trolltech.com/3.1/threads.html):

***SNIP
The Signals and Slots mechanism can be used in separate threads, as
long as the rules for QObject based classes are followed. The Signals
and Slots mechanism is synchronous: when a signal is emitted, all
slots are called immediately. The slots are executed in the thread
context that emitted the signal.
***SNIP

Part of my program consists of the following code:
bool
MyBUE::stopServer()
{
QProcess* proc = sd.getProcess(); // already running process
connect(proc, SIGNAL(processExited()), this,
SLOT(aServerHasDied()));
proc->kill();
cout << "###############1" << endl;
int counter = 10; // seconds
cout << "###############2" << endl;
while (proc->isRunning()) {
cout << "###############3" << endl;
m_waiter.wait(1000/*ms*/); // A QWaitCondition
cout << "###############4" << endl;
if (counter-- == 0) break;
cout << "###############5" << endl;
}
if (proc->isRunning()) {
cout << "###############6" << endl;
cout << "Could not terminate process." << endl;
cout << "###############7" << endl;
return false;
}
cout << "Server terminated by stopServer." << endl;
cout << "###############8" << endl;
return true;
}

void
MyBUE::aServerHasDied()
{
m_waiter.wait(5000/*ms*/);
cout << "###XXX###" << endl;
}

I get the following result:

###############1
###############2
###############3
<NO PAUSE!?>
###############4
###############5
<5 SECONDS PAUSE>
###XXX###
Server terminated by stopServer.
###############8


Could please someone explain to me this behaviour? I don't understand
it

Any help would be greatly appreciated

bye,
Frank Bossy
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-09-2003
"Frank Bossy" <> wrote...
> Dear group


Dear Frank,

>
> I don't quite understand the meaning of this paragraph in the qt docu
> (http://doc.trolltech.com/3.1/threads.html):
> [...]


Qt, threading, Slots, and related things are not defined by the
C++ language. They happen to be, therefore, outside the scope
of this newsgroup. Perhaps there is a better place to ask your
question, like the TrollTech tech support or, maybe the newsgroup
for your platform... Or even their web site, where I managed to
locate this archive: http://lists.trolltech.com/qt-interest/ ...

Victor


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A problem with slots and signals in a simple widget in Qt Alex M. C++ 4 08-02-2010 06:34 PM
(mandriva,eclipse,Qt) elementary problem : signals and slots lolveley Ruby 6 05-13-2009 09:47 AM
Problems with Signals & Slots of QT Christian Bruckhoff C++ 5 09-24-2006 03:19 PM
slots? SLOTS? tin gherdanarra Python 2 10-13-2005 12:31 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57