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

How to handle column width resizing event

I need to handle columns widths resizing in QTableWidget. How can I do this? -- I talk about event when cursor is under border between to header sections, left mouse button is down and mouse is moving.
Ufx
  • 2,595
  • 12
  • 44
  • 83
0
votes
2 answers

Synchronize QTableWidget cell with widget in the center of the cell

I use QCheckBox in QTableWidgetCell QWidget *widget = new QWidget(); QCheckBox *checkBox = new QCheckBox(); QHBoxLayout *layout = new…
Ufx
  • 2,595
  • 12
  • 44
  • 83
0
votes
2 answers

Error linking Qt based app

We're using a really old version of Qt, 1.1, I think. Circa 2000. It's for in-house use only, so there's little concern to upgrade at this time. Program is built on Windows using Visual Studio 2005. I know very little of Qt, other than what I've…
Jon
  • 1,675
  • 26
  • 57
0
votes
1 answer

Communication between multiple dialogs in Qt, using signals and slots or references

Im developing a Qt GUI application, with multiple QDialog's open at any given time. These dialogs need to communicate and notify with each other when special data is received on a separate network thread. Usually a dialog will hold a reference to at…
Daniel Mac
  • 400
  • 2
  • 14
0
votes
1 answer

How to delete object from its method?

I have a hierarchy of classes : struct A and struct B, which is stored in an instance of A. I run a method of A, which run a method of B, which downloads something asynchronously with connect signal of downloading to slot of B. After that I don't…
Nexen
  • 1,663
  • 4
  • 16
  • 44
0
votes
2 answers

Mechanism of QTimer

Suppose that timer is a object of QTimer, the timer's interval is iInterval and timer's timeout signal is connected to a slot sltTimeout(). I was just thinking what would happen if iInterval is smaller than the time it takes for sltTimeout() to run.…
waterd
  • 603
  • 1
  • 7
  • 23
0
votes
0 answers

qt4 signal is not emitted

I have a QT4 application which wraps libssh2 in order to communicate with the embedded devices on the network. The following snippet is making me crazy for a while. SSHClient ssh_client(host, 22); try { ssh_client.connect_to_host(USERNAME,…
Murat Şeker
  • 1,651
  • 1
  • 16
  • 29
0
votes
1 answer

Qt, data integrity when sending a reference as a signal

If I send a signal with a reference to an object, do I have any sort of guarantee that the slots will handle the signal before the object is subjected to changes by other parts of the program? Or do I have to send a deep copy of the object with the…
user3050215
  • 185
  • 1
  • 5
  • 14
0
votes
2 answers

Qt - open dialog when action triggered multiple times

I want a notice dialog to come up when an action has been triggered multiple times consecutively (so basically a bit like how StickyKeys is enabled). I understand that I can basically do connect(this->trigger, SIGNAL(triggered()), this,…
islandmonkey
  • 15
  • 1
  • 1
  • 7
0
votes
1 answer

Qt Signal not making it to the slot until mouserelease

I am having a problem where I emit a signal in a mouseMove event, but that signal does not get recieved by a slot on another object until i release the mouse. Details: I have a class called SelectableItem, which subclasses QGraphicsObject : #pragma…
jasonlg3d
  • 484
  • 2
  • 7
  • 18
0
votes
1 answer

Provide updates to Qt GUI from sub thread

I know very similar questions have been asked before, but I am unable to find an answer for my specific problem. I have a main (GUI) thread which upon button press initializes a worker thread to perform some analysis. I am using signals and slots to…
GTSeth
  • 1
  • 4
0
votes
1 answer

How to use QSignalMapper for a list of QAction items

I am developing a code snippet to perform similar, not identical actions when I click on the sub menu item list. Please check the attached snapshot. QSignalMapper is the best solution to connect multiple signals to the same slot. But I am not able…
cappy0704
  • 557
  • 2
  • 9
  • 30
0
votes
1 answer

Qt Signals & Slots: How do I get the data which was changed?

I have a QStandardModel. I connect its itemChanged signal to my own slot. m_model = new QStandardItemModel(this); connect(m_model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(changed(QStandardItem*))); The slot looks like this: void…
gartenriese
  • 4,131
  • 6
  • 36
  • 60
0
votes
3 answers

Trouble in reading from Serial port using QSerialPort

I have to develop a C++ program for an embedded FriendlyARM-based processor system. I use Qt Creator 3.0.0 (based on Qt 5.2.0) for desktop computer. My program should be able to read from serial port at Mini2440 FriendlyARM processor. Before going…
0
votes
3 answers

pass value to slot with QNetWorkAccessManager

I'm trying to use QsignalMapper to pass my String to img_loaded function, on finished SIGNAL. But I can not get any result, please help. QString mystring = "value"; QNetworkAccessManager *m_netwManager = new QNetworkAccessManager(this); …
Mega4alik
  • 597
  • 3
  • 10
  • 18