473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with QT / Threads / Signals / Slots

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
Jul 19 '05 #1
1 5941
"Frank Bossy" <fr*********@t-systems.com> 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
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ralph Sluiters | last post by:
Hi, i've got a small problem with my python-script. It is a cgi-script, which is called regulary (e.g. every 5 minutes) and returns a xml-data-structure. This script calls a very slow function,...
3
by: Sebastian Meyer | last post by:
Hi Newsgroup, i have some problems with using threads and signals in one program. In my program i have three threads running, one for checking a directory at a specified interval to see if new...
2
by: Holger Joukl | last post by:
Hi, migrating from good old python 1.5.2 to python 2.3, I have a problem running a program that features some threads which execute calls to an extension module. Problem is that all of a sudden,...
5
by: Christian Bruckhoff | last post by:
Hi. I got a problem with Signals and Slots of QT. The program i am speaking of u can find here: http://www.uni-koblenz.de/~brchrist/address/ If u look at gui.cpp u find a connect command at...
0
by: Pradnyesh Sawant | last post by:
Hello, i've written a small pyqt code which increments a counter in the backend, and prints it on the frontend. However, i'm passing a dummy string var along with it in the signal/slot mechanism....
6
by: geoffbache | last post by:
Hi all, I have a Python program (on UNIX) whose main job is to listen on a socket, for which I use the SocketServer module. However, I would also like it to be sensitive to signals received,...
0
by: Brian Vanderburg II | last post by:
I don't know if any such support is already built in, so I ended up making my own simple signals/slots like mechanism. If anyone is interested then here it is, along with a simple test. It can...
1
by: Scott SA | last post by:
On 5/1/08, Brian Vanderburg II (BrianVanderburg2@aim.com) wrote: Did you review this? <http://pydispatcher.sourceforge.net/> from what I understand is originally based upon this:...
3
by: ff | last post by:
Is it possible to create custom PyQt4 Slots, i have searched high and low to no avail; I have an application that can set animation speed to different levels, i want the user to alter this, now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.