Questions tagged [qt-signals]

Signals and slots are used for communication between objects. The signals and slots mechanism is a central feature of Qt and probably the part that differs most from the features provided by other frameworks.

Signals are emitted by an object when its internal state has changed in some way that might be interesting to the object's client or owner. Only the class that defines a signal and its subclasses can emit the signal.

When a signal is emitted, the slots connected to it are usually executed immediately, just like a normal function call. When this happens, the signals and slots mechanism is totally independent of any GUI event loop. Execution of the code following the emit statement will occur once all slots have returned.

Signals are automatically generated by the moc and must not be implemented in the .cpp file. They can never have return types (i.e. use void).

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5 (note about new signal syntax in Qt5). Also, here is documentation for using signals for QML.

507 questions
0
votes
1 answer

Cannot connect QFileSystemWatcher::directoryChanged to a lambda

As the title says, I'm trying to connect the QFileSystemWatcher::directoryChanged(const QString&) signal to a lambda, but when I compile it with g++ (7.2.1), I get the following error (abbreviated since SO won't let me post too much code): g++ -c…
JamesNZ
  • 187
  • 3
  • 7
0
votes
0 answers

qt connect rejected() signal but dialog won't close

Cancel-button is in a dialog and connects to QDialog::reject(). So if I click Cancel-button, the dialog will emit signal-rejected(). Then I connect another checkable-button with the QDialog::rejected(). Once checkable-button receives the…
Nick.Rhan
  • 167
  • 2
  • 7
0
votes
1 answer

Automatically create QStackedWidget pages based on Tuple

I'm fairly new to python, and I feel this is an advanced question, with that in mind it might be out of the scope of Stack Exchange. Please bear with me. I have a QTreeWidget and QStackedWidget. I have populated the QTreeWidget using a…
artomason
  • 3,625
  • 5
  • 20
  • 43
0
votes
1 answer

Connecting signal and slot not working Qt

I mostly copied, pasted the code from Here, and implemented them in a small new program like this: In mybutton.h: class MyButton : public QPushButton { Q_OBJECT public: MyButton(QWidget *parent = Q_NULLPTR); QVector
Theodore Tang
  • 831
  • 2
  • 21
  • 42
0
votes
1 answer

Connect slots from another class not working in Qt

I have this class in button.h: class Buttons : public QObject { Q_OBJECT public: Buttons(); QVector buttons; public slots: void getBtnInfo(); }; and in mainwindow.cpp, I connect like this: Buttons mButtons; for(int i =…
Theodore Tang
  • 831
  • 2
  • 21
  • 42
0
votes
1 answer

Pyqt4 Qcombobox signal is not firing upon user input but it does when done with .setCurrentIndex

The QComboBox currentIndexChanged Signal is not firing when a new item is selected from user. But it does fire when .setCurrentIndex is used within the code. (line 91 and 92). I have a QTabWidget. In tab1 I have a Qvbox into which three Qhboxes are…
SteffenUM
  • 3
  • 2
0
votes
1 answer

QT/QML Business logic separated from the UI

I'm trying to put the business logic in Main.qml and the UI in MainForm.ui.qml but I can't connect both by widget id. MainForm.ui.qml: import QtQuick 2.8 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 Page { id: page header: TabBar {…
Aubin
  • 14,617
  • 9
  • 61
  • 84
0
votes
0 answers

Getting the emitted value by pyqtsignal in QThreads in PyQt

I am trying to get the value emitted by Class Qthread's signal without using the function I am calling alert box when the user chooses to exit and press [X] button on GUI so I called this alert box by the means of threading to ensure that my GUI…
Aadit
  • 199
  • 1
  • 6
  • 17
0
votes
3 answers

C++ signal does not get caught on QML side

I was checking this example and I cannot catch Qt C++ signal in QML. Here is my UeSettings class header: #ifndef UESETTINGS_H #define UESETTINGS_H #include #include #include #include #include…
KernelPanic
  • 2,328
  • 7
  • 47
  • 90
0
votes
3 answers

No such slot when connecting widget signal with parent widget slot

I have the following classes: class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QStringList pluginsToStart, QWidget *parent = 0); ~MainWindow(); // some other stuff public slots: void…
M F
  • 323
  • 1
  • 3
  • 15
0
votes
1 answer

QT Connect Slot / Signal not working

I am having trouble to connect a Signal to a Slot in the following code: #include "myserver.h" MyServer::MyServer(QObject *parent) : QTcpServer(parent) { } void MyServer::StartServer() { if(listen(QHostAddress::Any, 45451)) { …
0
votes
1 answer

Updating mapping when using QSignalMapper

I have created a QPushButton in the last column of tableview (which contains ip address of the connected clients to my application). With that button I am able to disconnect the connected client in that particular row using button release signal and…
tanmayb
  • 13
  • 6
0
votes
1 answer

Qt signal/slots and C++ Lambda expression

Why this doesn't work ? Class inherit from QObject b is Class child. bar is Foo child. void Class::method(Foo& b) { Bar* bar = b.getBar(); QObject::connect(bar, &Bar::s1, [&]{ auto x = bar->x(); // this line throw an exception read…
Houss_gc
  • 727
  • 5
  • 27
0
votes
2 answers

How to connect signal and slot without using connect function?

Is there a way to connect signal and slot without using connect function? If a way exists, please give some examples.
lens
  • 133
  • 1
  • 11
0
votes
1 answer

QML connect() passing extra arguments

I want to connect signal_A(C) from itemA to function_B(currentIndex,C) from itemB. How do I connect them? When its signal_A(C) -> function_B(C) it will be: itemA.signal_A.connect(itemB.function_B); But I am not sure how to link them when there is…
laurapons
  • 971
  • 13
  • 32