signals

Qwt for Qt: How to connect to signal with new signal/slot flavour?

爷,独闯天下 提交于 2019-12-25 16:55:55
问题 I want to to connect to legend-label SIGNAL checked. With Qts old Signal/Slot-Syntax all is perfect, but i want to use the new connection to enable compile-time check? Any idea on how to connect it via new Signal/Slot-Syntax? This is my code: connect( m_plotLegend, SIGNAL( checked( const QVariant &, bool, int ) ), SLOT(legendChecked( const QVariant &, bool ) ) ); //connect(m_plotLegend, &QwtLegend::checked, this, &MeasurePlot::legendChecked); With oldy syntax all is fine, with the new syntax

pthread_cond_wait never unblocking - thread pools

匆匆过客 提交于 2019-12-25 08:13:52
问题 I'm trying to implement a sort of thread pool whereby I keep threads in a FIFO and process a bunch of images. Unfortunately, for some reason my cond_wait doesn't always wake even though it's been signaled. // Initialize the thread pool for(i=0;i<numThreads;i++) { pthread_t *tmpthread = (pthread_t *) malloc(sizeof(pthread_t)); struct Node* newNode; newNode=(struct Node *) malloc(sizeof(struct Node)); newNode->Thread = tmpthread; newNode->Id = i; newNode->threadParams = 0; pthread_cond_init(&

Qt Signals and Slots - nothing happens

笑着哭i 提交于 2019-12-25 07:40:01
问题 I'm currently trying to connect a QML Signal to a C++ Slot unsuccessfully. I just had a look on several other examples but I think i didn't got it with how to get the root object of a qml document... My problem is, it seems like the signal will be sent from the qml file, but not received in the cpp file. There are no errors when I execute this code. //Counter.h #ifndef COUNTER_H #define COUNTER_H #include <QObject> class Counter : public QObject { Q_OBJECT private: int counter; public:

How to detect if variable uninitialized/catch segfault in C

社会主义新天地 提交于 2019-12-25 07:09:10
问题 I currently have a program where I need to test if a variable passed in as a parameter is uninitialized. So far it seems like this is pretty hard to do in C, so my next idea was to invoke a signal handler to catch the segfault. However, my code isn't calling upon the signal handler when it tries to access the uninitialized variable, like so: void segfault_sigaction(int signal, siginfo_t *si, void *arg) { printf("Caught segfault at address %p\n", si->si_addr); exit(0); } void myfree(void*p,

SIGCHLD causing segmentation fault, not going into handler

一曲冷凌霜 提交于 2019-12-25 06:55:11
问题 I'm trying to make a simple shell and am adding in functionality to run processes in the background with &. In my main method I basically have: int main() { if (signal(SIGCHLD, handle) == SIG_ERR) perror("Cannot catch SIGCHLD"); pid_t child = fork(); if (child == 0) execvp(command, arguments); else { if (background == 1) { printf("1"); backgroundList(command, child); printf("2"); } else waitpid(child, NULL, 0); } } And for my handler I have: void handle(int s) { printf("a"); if (signal

Passing Arguments with Newstyle signals in PyQT

我的未来我决定 提交于 2019-12-25 04:53:38
问题 I've been having some trouble with a set of dynamically created buttons in PyQT. I'm using a list to create buttons corresponding to different values. Because each button is different, I need to have them pass an argument to the "Button Clicked" function identifying themselves separately so I can perform different actions with them. Here is what I have so far: for x in self.buttons: name = str(x) button = QtGui.QPushButton(Frame) button.setText(name) cp_result = self.changeProject(name) if cp

Blocking signals causes boost process not to work

你离开我真会死。 提交于 2019-12-25 03:51:42
问题 In the code below the class Process can run a process using boost process in asynchronous mode and can kill it if it times out. Now in order to shut it down, I block all the signals in all threads and create a specific thread signal_thread to handle signals. On doing this the program stops working. I guess this is probably because the parent process can no longer receive the signal SIGCHLD and know that the child process has finished executing. #include <iostream> #include <csignal> #include

Resume a program if variable's value changes

二次信任 提交于 2019-12-25 02:06:20
问题 Is there a way in c / c++ to pause a program (might be with SIGSTOP ), and then to continue ( SIGCONT ?) it when another thread changes a value of some variable? For example: int main(void) { int a = 0; createThread(&a); //creates a thread which will change a's value pauseMyself(); //pauses main process till a's value is changed /* main process gets here only when a's value has been changed */ fprintf(stderr, "a's value has been changed\n"); return 0; } I want to see if it is possible so I

How function signal() works in C with SIGINT

大城市里の小女人 提交于 2019-12-25 01:44:25
问题 #include <stdio.h> #include <signal.h> void f( int ); int main () { int i ; signal ( SIGINT , f) ; for (i =0; i <5; i ++) { printf ( " hello \n " ) ; sleep (10) ; } } void f( int signum ){ //signal ( SIGINT , f) ; printf ( " OUCH !\n ") ; } I am try to learn handle signals in c. In code above i could not understand the way that function signal works. I understand that when i execute this code when i press control-c function f will be executed and would interrupt the loop.But when i press

Qt5: Though connected, Signal emmited but Slot not being called

北战南征 提交于 2019-12-25 01:35:32
问题 So I have a Qt class MyQtClass , and a QOject inherited class Sender . I want to access the Ui from the Sender class (Which by the way only consists static members), so I set up the static Sender& instance() , static void emitSignal() functions and the QSignal Q_SIGNAL void mySignal() in the Sender class (See the code below). In the Qt-class-header MyQtClass.h I've set up the QSlot Q_SLOT void mySlot() . I connect those two slots in the main.cpp ( const bool connected = QObject::connect(