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 execute custom code on pressure of Qt button

In QT Designer I have defined a button loadValues_btn and associated the signal pressed() to the custom slot loadValues() Then in Python, after having loaded the .ui file with the PyQt library, I have defined the method loadValues() in the…
davide
  • 221
  • 3
  • 16
0
votes
1 answer

Qt: Force a repaint to update text from fast button clicks?

I have some very simple code that displays a QPushButton which, when clicked, updates a spinbox with a random number 1 - 100. The problem is I can click the button many times in quick succession and only see one or two updates in the spinbox. How…
Ian
  • 73
  • 6
0
votes
0 answers

PyQt QMessageBox crush program

I have a problem with my code. How to correct the code below to QMessageBox not crash program? I don't know why this problem really exists. I tried run QMessageBox in new QThread but it changed nothing. import sys from time import sleep from…
Andy
  • 1
  • 3
0
votes
1 answer

How to catch a Signal from QMainWindow class by another thread on PySide?

I have a MainWindow class which have a Gui application running on it and i want that every time i click on a button from my application a signal is emitted and caught by another thread. There is my example code (sorry for not posting my real code…
0
votes
1 answer

Error only when building Qt project from command line

I have a big problem. I created a dummy project to isolate my error. Because is a project with 6 files and it is unfeasible to add all the code here I created a github project and added all the code there while describing the idea here. You can take…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
0
votes
0 answers

Qt sending image between dialog

I'm writing a simple application with 2 dialogs, the first for one original image, which is sent to another dialog and processed. Then the image processed is sent back to the first dialog: ImageDialog::ImageDialog(QWidget *parent) : QDialog(parent),…
0
votes
1 answer

Program crashes because of wrong usage of slots and signals

What I'm trying to do is to call an time consuming operation (MockClamWrapper::loadDatabase()) in a separate thread at the moment of creation of my window and then to update my window once the operation is completed. Here is the code that I…
AndreySarafanov
  • 804
  • 5
  • 20
0
votes
1 answer

Qt Signals and Slots with Boost::smart_ptr

So what I am trying to do is use Qt signals and slots to pass around an image through a smart_ptr so that it will delete itself when everything that needs to use the data is done accessing it. Here is the code I have: Class A, inherits…
colossus47
  • 99
  • 9
0
votes
1 answer

How to make QListView emit a custom SIGNAL and call a custom SLOT to handle it?

How can I make a QListView emit a custom SIGNAL called onListViewItemSelectionChanged whenever its item selection has been changed either by clicking or by using the up and down arrow keys, so that I could assign a custom SLOT called…
Bhaddiya Tanchangya
  • 331
  • 1
  • 5
  • 12
0
votes
1 answer

Click button cause multiple function calls

I develop a python program. The following code is my program. The problem is when I click self.ui.Restart_Btn which call self.restartClicked() method and I click self.ui.B11, it call the method self.boardClicked() twice (which it should call only…
Pandarian Ld
  • 727
  • 3
  • 13
  • 25
0
votes
3 answers

Substitute for sleep function in Qt/C++

So I am writing a program that displays each letter of a word for 1 second with a 1 second interval between the letters. (It's for a spelling exercise for grade 1). I am currently using the sleep function to "pause" the program for 1 second before…
Armand Maree
  • 488
  • 2
  • 6
  • 21
0
votes
1 answer

QT Signal / Slot

I've got a question about signals and slots. In my app, I want to connect a signal from one object to a textEdit in a dialog window. My signal emits a QString; if I violate encapsulation (by making the UI public instead of private) and connect the…
Azraith Sherkhan
  • 131
  • 2
  • 11
0
votes
1 answer

Qtoolbar toggle show hide on Qmenu

How to add slot to toggle show and hide the toolbar in qmenu? This my code: #include "mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setMinimumSize(800, 600); CreateAct(); CreateMenus(); …
0
votes
1 answer

QListWidget::itemSelectionChanged() fired twice with keyboard

I'm using a QListWidget to select files within a list, on selection I read this file, in case of error I clear all selections and popup an error. Everything works fine using only mouse, but when using keyboard arrows, on a bad file, the signal fire…
Giacogiac
  • 189
  • 1
  • 11
0
votes
2 answers

Slot is not being used

I'm learning the signals/slots in Qt and I have found a problem. I need to create my own slot that is called when items on QGraphicsScene (in QGraphicsView) are moved or selected. I'm starting with a simple app that has one widget and on it is…
mishan
  • 1,177
  • 3
  • 19
  • 42