signals-slots

PySide (or PyQt) signals and slots basics

别说谁变了你拦得住时间么 提交于 2019-11-27 07:15:53
问题 Consider a simple example like this which links two sliders using signals and slots: from PySide.QtCore import * from PySide.QtGui import * import sys class MyMainWindow(QWidget): def __init__(self): QWidget.__init__(self, None) vbox = QVBoxLayout() sone = QSlider(Qt.Horizontal) vbox.addWidget(sone) stwo = QSlider(Qt.Horizontal) vbox.addWidget(stwo) sone.valueChanged.connect(stwo.setValue) if __name__ == '__main__': app = QApplication(sys.argv) w = MyMainWindow() w.show() sys.exit(app.exec_()

Qt: SIGNAL, SLOT Macro declaration [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 07:11:23
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Is it possible to see definition of Q_SIGNALS, Q_SLOT, SLOT(), SIGNAL() macros? (Qt) I couldn't find on Google, the declaration of the macros, SIGNAL and SLOT, in Qt. When we say, connect(button1, SIGNAL (clicked()), this, SLOT (slotButton1())); I would like to understand, which all kinds of parameters does the highlighted macros accept? Any link to doc would be appreciated. EDIT 1 The link I got through Neil's

PyQt: How to send a stop signal into a thread where an object is running a conditioned while loop?

与世无争的帅哥 提交于 2019-11-27 07:08:54
问题 I'm doing some multi-threading. I have a worker class with a work method, which I send into a separate QThread . The work method has a conditioned while loop inside. I want to be able to send a signal to the worker object to stop it (changing the _running condition to false). This will cause the while loop to exit, and a finished signal to be sent from the worker object (which is connected to the quit slot of the worker's thread). The false condition is sent to the worker object via a signal,

Which C++ signals/slots library should I choose?

我们两清 提交于 2019-11-27 06:40:52
I want to use a signals/slots library in a project that doesn't use QT. I have pretty basic requirements: Connect two functions with any number of parameters. Signals can be connected to multiple slots. Manual disconnection of signal/slot connection. Decent performance - the application is frame-based (i.e. not event-based) and I want to use the connections in each frame. I've read a comparison between libsigc++ and Boost.Signals . I've also read that Boost.Signals suffers from poor performance. However, I know there are other libraries and I'm still not sure which library should I choose. Are

How to intercept ALL signals emitted by a given event in Qt?

Deadly 提交于 2019-11-27 06:00:59
问题 I can imagine that there might be quite a few of them depending on the event, but at the same time, I guess this can be a best way to debug, and an interesting lesson. Why would I need it? I'm using some custom class based on the QWidget , which does not expand when I de-attach a QDockWidget based in the same window. Knowing what signals are emitted when this dock widget is being de-attached would help me to chose which method I need to overwrite in my custom class. In other words, I don't

How to pass arguments to callback functions in PyQt

三世轮回 提交于 2019-11-27 04:53:28
I have around 10 QAction (this number will vary in runtime) in a toolbar, which all will do same thing, but using different parameters. I am thinking to add parameter as an attribute to QAction object, and then, QAction's triggered signal will also send object's itself to the callback function, so that I could get required parameters for the function. I have actually 2 questions about this: Can it be done? Is there a better way of doing this? You can send the action object itself using a signal mapper . However, it may be better to simply send an identifier and do all the work within the

Does large use of signals and slots affect application performance?

三世轮回 提交于 2019-11-27 04:17:45
问题 The question is just done for educational purpose: Does the use of 30-50 or more pairs of signals and slots between two object (for example two threads) affect the application performance, runtime or response times? 回答1: First of all, you should probably not put any slots in QThreads. QThreads aren't really meant to be derived from other than by reimplementing the run method and private methods (not signals!). A QThread is conceptually a thread controller, not a thread itself. In most cases

QT : Templated Q_OBJECT class

眉间皱痕 提交于 2019-11-27 04:11:33
Is it possible to have a template class, which inherit from QObject (and has Q_OBJECT macro in it's declaration)? I would like to create something like adapter for slots, which would do something, but the slot can take arbitrary number of arguments (number of arguments depends on the template argument). I just tried doing it, and got linker errors. I guess gmake or moc is not getting called on this template class. Is there a way to do this? Maybe by explicitly instantiating templates? It is not possible to mix template and Q_OBJECT but if you have a subset of types you can list the slots and

How to pass arguments to callback functions in PyQt

孤者浪人 提交于 2019-11-27 03:58:24
问题 I have around 10 QAction (this number will vary in runtime) in a toolbar, which all will do same thing, but using different parameters. I am thinking to add parameter as an attribute to QAction object, and then, QAction's triggered signal will also send object's itself to the callback function, so that I could get required parameters for the function. I have actually 2 questions about this: Can it be done? Is there a better way of doing this? 回答1: You can send the action object itself using a

How to emit cross-thread signal in Qt?

落爺英雄遲暮 提交于 2019-11-27 03:57:15
问题 Qt documentation states that signals and slots can be direct , queued and auto . It also stated that if object that owns slot 'lives' in a thread different from object that owns signal, emitting such signal will be like posting message - signal emit will return instantly and slot method will be called in target thread's event loop. Unfortunately, documentation do not specify that 'lives' stands for and no examples is available. I have tried the following code: main.h: class CThread1 : public