Questions tagged [signals-slots]

Signals and slots is a mechanism for implementing the observer pattern.

Signals and slots is a mechanism for implementing the observer pattern. It has many implementations in various languages:

See also:

1653 questions
12
votes
2 answers

How to pass Qt::ConnectionType to QObject::connect when connecting a lambda?

I am connecting lambdas to QObject's signals: QObject::connect(handle, &BatchHandle::progressMax, [this](const ProcessHandle* const self, const int value) { this->maxProgress(value); }); The code above compiles with no…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
12
votes
3 answers

Why are signals and slots better than plain old callbacks?

Newbie to C++ here. I was reading A Deeper Look at Signals and Slots, which claims that 1) callbacks are inherently type-unsafe, and 2) to make them safe you need to define a pure virtual class wrapper around your function. I'm having a hard time…
James Ko
  • 32,215
  • 30
  • 128
  • 239
12
votes
1 answer

Is there a way trigger a signal from another signal in Qt?

I already have an application in place and am tweaking it now. In this regard, I am introducing a new signal, which has to be emitted when another signal is emitted. Is this possible in Qt? Writing a slot just to emit this signal feels so primitive…
jxgn
  • 741
  • 2
  • 15
  • 36
12
votes
4 answers

QLabel click event using Qt?

I'm new in Qt and have a question. I have QLabel and QLineEdit objects, and when QLabel text is clicked on, I want to set this text in QLineEdit. Also I have read that QLabel has not clicked signal. Can you explain how can I do this and write code…
Nicholas
  • 147
  • 1
  • 2
  • 6
12
votes
2 answers

Create PyQt menu from a list of strings

I have a list of strings and want to create a menu entry for each of those strings. When the user clicks on one of the entries, always the same function shall be called with the string as an argument. After some trying and research I came up with…
11
votes
1 answer

How to send a Qt signal containing a cv::Mat?

In short, I get following error: QObject::connect: Cannot queue arguments of type 'cv::Mat' (Make sure 'cv::Mat' is registered using qRegisterMetaType().) What I'm trying to do is send a signal containing two cv::Mat images from a QThread to the…
Raf Berkvens
  • 167
  • 1
  • 8
11
votes
5 answers

How to pass arguments to callback functions in PyQt

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…
yasar
  • 13,158
  • 28
  • 95
  • 160
11
votes
1 answer

How to implement a simple button in PyQt

I want to implement a simple button in PyQt which prints "Hello world" when clicked. How can I do that? I am a real newbie in PyQt.
Abid Rahman K
  • 51,886
  • 31
  • 146
  • 157
11
votes
6 answers

How to pass variables to slot methods in QT?

I'm making a little chat messenger program, which needs a list of chat channels the user has joined. To represent this list graphically, I have made a list of QPushButtons, which all represent a different channel. These buttons are made with the…
Neko
  • 3,550
  • 7
  • 28
  • 34
11
votes
3 answers

waiting for a signal

I am working on an application which uploads the content of the file to server. To upload the file to server I am using ‘QNetworkAccessManager’ class. Since it works as asynchronous way, I changed it to work as synchronous way by using QEventLoop.…
Umesha MS
  • 2,861
  • 8
  • 41
  • 60
11
votes
3 answers

How to process signals in a Qt subclass?

How do I process a signal of in a subclass? Let's say my subclass is derived from QTextEdit and is interested in the signal textChanged. It seems silly to connect an object to itself, I should be able to simply override the textChange method --…
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281
11
votes
2 answers

How to hide a layout in PyQt?

My code contains a vertical box layout which is a combination of a vertical box layout in left and one at right. I was wondering if there is a way to hide the left layout with all its widgets when a certain signal is emitted.
sparrow
  • 297
  • 1
  • 5
  • 16
11
votes
3 answers

Fastest C++ Signal/Slot Lib without dependency

I am going to pass data up/down a 5-10 layered object using signals and slots. Which should result in a few thousand signal per sec. Which is far form "I clicked a button". All my object will also signal them self on a timer about every 100ms so…
JP.
  • 495
  • 1
  • 9
  • 20
11
votes
2 answers

(How) is it possible to bind/rebind a method to work with a delegate of a different signature?

I'm a c++ developer having used signals & slots in c++ which to me seems to be analogous to delegates in c#. I've found myself at a loss in searching for the functionality provided by "bind", and feel I must be missing something. I feel like that…
Catskul
  • 17,916
  • 15
  • 84
  • 113
11
votes
3 answers

Turn off PyQt Event Loop While Editing Table

I'm developing a GUI with PyQt. The GUI has a qListWidget, a qTableWidget, and a plot implemented with Mayavi. The list refers to shapes that are plotted (cylinders and cones for example). When a shape is selected in the list, I want the shape's…
flutefreak7
  • 2,321
  • 5
  • 29
  • 39