473,657 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::stopServ er()
{
QProcess* proc = sd.getProcess() ; // already running process
connect(proc, SIGNAL(processE xited()), this,
SLOT(aServerHas Died()));
proc->kill();
cout << "############## #1" << endl;
int counter = 10; // seconds
cout << "############## #2" << endl;
while (proc->isRunning()) {
cout << "############## #3" << endl;
m_waiter.wait(1 000/*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::aServerH asDied()
{
m_waiter.wait(5 000/*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 5967
"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
2079
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, with a duration of 10-40 seconds. To avoid delays, i inserted a cache for the data. So, if the script is called, it returns the last caculated data-structure and then the function is called again and the new data is stored in the cache. (There is no...
3
1744
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 data arrived, one waiting for work and the main thread. My problem is the following: I want to shutdown the program via a signal, so i used the signal module. I know, that signal handling mus be done by the main thread, the signal
2
2050
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, I cannot stop the program with a keyboard interrupt any more; the installed signal handler does not seem to receive the signal at all. This happens both if I rebuild this extension using python 2.3 headers/library and if I simply use the old...
5
2225
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 line 27. I would read this command like this: "If pushButtonAddPerson got clicked call the function addPerson() of this GUI-Object" So this connect should call the function starting on line 50. But if i start
0
1937
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. The problem is that from the 2nd call onwards, the string gets printed, but NOT in the 1st call. (eg, in the foll code i get:- 1, (2, 'a'), (3, 'a'), ...) The code is:- ************************************************** import time import sys
6
2380
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, which it isn't if it's listening on the socket. ("signals can only be received between atomic actions of the python interpreter", presumably - and control will not return to Python unless something appears on the socket). Does anyone have a tip of a...
0
1002
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 connect to normal functions as well as instance methods. It also supports weak connections where when an object is gone, the slot is gone as well, the slot just holds a weak reference to the object. Brian Vanderburg II
1
1783
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: <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/87056> and subsequently integrated into this:
3
2556
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 quite clearly i can write a single function to control setting any speed with something like: def setSpeed(self, speed): some code in here to set speed
0
8407
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.