Questions tagged [qt-slot]

53 questions
97
votes
6 answers

Passing an argument to a slot

I want to override mouseReleaseEvent with a bunch of QActions and QMenus... connect(action1, SIGNAL(triggered()), this, SLOT(onStepIncreased())); connect(action5, SIGNAL(triggered()), this, SLOT(onStepIncreased())); connect(action10,…
Fatih Arslan
  • 1,054
  • 1
  • 9
  • 10
35
votes
3 answers

My signal / slot connection does not work

I repeatedly see people having problems with slots not being called. I would like to collect some of the most common reasons. So maybe I can help people and avoid a lot of redundant questions. What are reasons for signal / slot connections not…
Silicomancer
  • 8,604
  • 10
  • 63
  • 130
15
votes
1 answer

Connecting C++ with QML using Q_INVOKABLE

I have a Qt function: void MainWindow::button_clicked(Qstring a, Qstring b, Qstring c, Qstring d) I collect data from QML and I want to pass data to this function which is in Qt. So I know I need to use Q_INVOKABLE but don't know really how to use…
user123_456
  • 5,635
  • 26
  • 84
  • 140
6
votes
1 answer

Why a new signal for socket::readyRead() is executed, even when its earlier slot is still processing?

According to following post an emitted signal is served, only once the currently executing slot completes. Wait for a SLOT to finish the execution with Qt I have a client-server communication app based on ssl socket, which is single…
iammilind
  • 68,093
  • 33
  • 169
  • 336
5
votes
2 answers

QSpinBox and QDoubleSpinBox do not call method on valueChanged

All i want to do is call a method when the value of a qspinbox and a doublespinbox are changed. I do not need the actual value from the spinbox being changed, i just want it to trigger the calling of another method. Why does the code below not error…
JokerMartini
  • 5,674
  • 9
  • 83
  • 193
5
votes
1 answer

How can I send a python dictionary to a QML interface with a Signal?

I want to send dictionaries, containing data that I need to use to dynamically create qml objects, from a PySide2 class to a QML interface and since I need to do it in response to certain events, I need to use signals and slots. Since I've just…
Lando1784
  • 426
  • 1
  • 4
  • 12
5
votes
1 answer

Optional Signal Arguments

I have a function which has default keyword arguments. I'm having trouble implementing this as I keep getting an error that if my signal has two arguments then I need to pass both arguments. Is there any way around this? class Controller(QWidget): …
aoh
  • 1,090
  • 2
  • 13
  • 25
5
votes
3 answers

QLineEdit editingFinished signal twice when changing focus?

I've found a few similar questions on this but these appear to refer to cases where a message box is used in the slot handler. In my case I am a bit stuck as I am getting the editFinished signal twice even when my slot handler is doing nothing. For…
Toby
  • 131
  • 2
  • 8
4
votes
1 answer

Is it possible to get a return value from a QRemoteObject Dynamic Replica slot?

I am unable to call a slot returning a value on a QRemoteObjectDynamicReplica. It seems that InvokeMethod on Replica doesn't support return value. I have only succeeded in calling void returning slots and even in this case, in DirectConnection mode,…
Daes
  • 81
  • 8
4
votes
1 answer

Is it safe to connect a signal to a pure virtual slot in a constructor of a base class?

I ask myself if the following code is safe : #include #include #include #include class Base : public QObject { Q_OBJECT public: Base() { // is it safe to do that ? …
Fryz
  • 2,119
  • 2
  • 25
  • 45
3
votes
1 answer

Has `@pyqtSlot()` same effect on a nested function?

1. Intro I'm working with PyQt5 in Python 3.7 on a multithreaded application, for which I rely on the QThread. Now suppose I have a class derived from QObject. Within that class, I define a function annotated with @pyqtSlot: from PyQt5.QtCore import…
K.Mulier
  • 8,069
  • 15
  • 79
  • 141
3
votes
1 answer

QWidget with doubleclick

I want to be able to double click a QPushbutton instead of a single click. What I tried: connect(pb, SIGNAL(doubleClicked()), this, SLOT(comBtnPressed())); Error says "QObject::connect: No such signal QPushButton::doubleClicked()" I chose…
GeneCode
  • 7,545
  • 8
  • 50
  • 85
2
votes
1 answer

What effect will exist when using any 'return' statement inside Qt's slot

For instance, I connect the 'clicked' signal of QPushButton to a function named 'func_with_return'. Assumes that there are just three statements in this function: The first one is 'print('start')', the second one is 'return 1' and the last one is…
Hobin C.
  • 671
  • 1
  • 8
  • 17
2
votes
1 answer

PyQt5: Slot in separate file not being called

I currently have a basic GUI right now with each page in its own file. I can navigate to and from each page with no problem, but I'm having difficulty simply passing a search query to another Widget. Here's where I setup the connections in the main…
2
votes
1 answer

QMetaMethod::invoke() with argument defaults

When calling QMetaMethod::invoke() on a method that contains default arguments, the invoke fails. class MyClass : public QObject { Q_OBJECT public: Q_INVOKABLE MyClass() : QObject(nullptr){} public slots: int MyMethod(int a = 0) { …
mrg95
  • 2,371
  • 11
  • 46
  • 89
1
2 3 4