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
2 answers

what's the utility of signals and slots

Actually I have been using signals and slots while programing in Qt. The main use of signals and slots are in the UI interaction, for example a clicked button sends a signal that will invoke a slot to perform action. I know that it's possible to use…
rednaks
  • 1,982
  • 1
  • 17
  • 23
0
votes
1 answer

QThread Slots behavior

I am new to C++ and Qt and I am wondering what happens if I emit a signal in object1 running in thread1, to another object2 running in another thread2 and object2 is running an infinite loop for processing? Will the slot in object2 never be called…
Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
0
votes
0 answers

QEventLoop usage(signals and slots)

I have an application which contains such lines. emit WindowAdded(settings->WindowType);//!!!!!!!!!!!!!! MyWindow *widget = new MyWindow(0,settings,currentWindowIndex); The signal changes value of currentWindowIndex, but it didn't work because of…
zuzman322
  • 124
  • 8
0
votes
3 answers

Qt Signals and slots mechanism blocked by a loop in main

I have a following situatuion. 2 Socket objects are created in the main in a for loop (the original problem has 1000 objects). Upon creation the start() method is invoked. start() creates a QTcpSocket which tries to connect to some host. Socket has…
TheMeaningfulEngineer
  • 15,679
  • 27
  • 85
  • 143
0
votes
3 answers

QtCore.QObject.connect in a loop only affects the last instance

I have got a loop. I created a QCheckBox and put it in a QTableWidget cell, and everything is Ok. In each step of loop I have called a connect function, for myslot SLOT, but only the last QCheckBox instance is applied. I googled a lot and have found…
zoyak
  • 19
  • 5
0
votes
1 answer

QTcpSocket's QThread not emitting finished signal

I have created a (somewhat) simple telnet server, which creates a new thread for each connection: void TelnetServer::incomingConnection(qintptr socketDescriptor) { TelnetConnection *thread = new TelnetConnection(socketDescriptor, this); …
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
1 answer

How to process signals/idle inside a QThread?

I have created a simple threaded network server. The main.cpp calls app.exec() to idle, and the thread fires off as expected once I establish a connection. In the thread's run() function, I hookup a signal from readyRead to a slot called…
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
2 answers

Qt: Access Widget from main function and implement exit button

I want to implement an exit button in my application, which has the following setup: I have a main function which looks like this: QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); I also have a mainWindow function which has…
BlackMamba
  • 1,449
  • 2
  • 12
  • 18
0
votes
1 answer

PyQt5 in what module is the emit method found?

It would be helpful somebody run this code for me as a sanity check. Python 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>>from PyQt5.QtCore import…
ADB
  • 1,210
  • 4
  • 15
  • 23
0
votes
1 answer

How to Disconnect all connected in QtScript

I use QtScript in my application. Scripts are written by users. As example script like this: // function testIteration() { if () { …
Sacha_D
  • 68
  • 1
  • 10
0
votes
1 answer

PyQt - How to connect signat in to custom slot / function

I am new to PyQt programming. I am trying to create simple application but struck while connecting signal to custom function. Every time i run i get the same error "AttributeError: 'AppGui' object has no attribute 'chk_fun'" Here is the simple…
sundar_ima
  • 3,604
  • 8
  • 33
  • 52
0
votes
1 answer

Pyside QgraphicsScene can't capture mouse events

I can't find the way to attach mouse events to scene. Without View all events are capcured, but when commented out, only mousePressEvent works. Please, help. from PySide import QtGui, QtCore class Window(QtGui.QMainWindow): def __init__(self): …
Alex
  • 3,167
  • 6
  • 35
  • 50
0
votes
1 answer

Trouble Connecting QPushButton Signal to QGraphicsView Slot

I'm having trouble connecting a signal in a QPushButton to a slot in my QGraphicsView. My Push Button Header: class Button : public QPushButton { Q_OBJECT public://public constructors / destructors Button(Game_state * game_state,…
JonMorehouse
  • 1,313
  • 6
  • 14
  • 34
0
votes
1 answer

Object::connect: No such signal when obj is returned as shared_ptr

Using Qt's signal & slot, I get error: Object::connect: No such signal FvOverlayPolygon::mouseHoveredOnElemSig(rf::AbstractFvOverlay*) My other connects work fine and I've checked everything I can think of (refered to 20 ways to debug Qt signals…
IsaacS
  • 3,551
  • 6
  • 39
  • 61
0
votes
1 answer

QTableWidget cellClicked signal not working

I have a QTableWidget in my application and I have connected the cellClicked(int,int) signal to a slot. But this code in the slot doesn't get called at all when a cell is clicked. Please let me know how this can be resolved. This is my…
Rakesh K
  • 8,237
  • 18
  • 51
  • 64
1 2 3
33
34