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

pass value to slot and get feedback to its call function with QNetWorkAccessManager

I want to use QNetWorkAccessManager to finish HTTP-GET and try to pass a value to the reply_finished slot,then I hope get feedback from the slot to its call function(e.g. MainWindow).I used https://stackoverflow.com/a/21362640/7519936 and pass a…
0
votes
1 answer

is there an event/signal which happens when the QMdiarea become empty?

I want to implement a code when QMdiarea is empty i.e. (has no QSubWindow children). For example: is there an event or signal which happens when the QMdiarea become empty?
Lion King
  • 32,851
  • 25
  • 81
  • 143
0
votes
1 answer

Qt: Connect slot for a class defined within a QObject class

I have class MainWindow that will contain several QWidgetTables with their own headers and other members. For now, I would like to define custom table classes within class MainWindow because they are pretty simple. See Example below: class…
E. Pratt
  • 84
  • 2
  • 8
0
votes
1 answer

Is there any flag to indicate the QT mainwindow rendering is finished

is there any flag to find out the QT has finished rendering on the screen. I want this flag to notify the another window to be displayed.
VamsiKrishna Neelam
  • 103
  • 1
  • 1
  • 11
0
votes
1 answer

Switching two mainwindows

I am new to QT GUI programming. I am trying to test switching two mainwindows continously by using show and hide. I have created a simple code in main.cpp main(){ QApplication a(argc , argv) Mainwinodw1 *window1 = new…
VamsiKrishna Neelam
  • 103
  • 1
  • 1
  • 11
0
votes
0 answers

QT Opening a new Window in a class

So I currently try to make a puzzle game where a new window shall be opened when I click the Playbutton, receiving a SIGNAL from the button to open the SLOT function openNewWindow Which looks like this: Header: class PuzzleField : public…
0
votes
1 answer

signals and slots qt close slot

I made a window and a button in it. I want the button to close the window when clicked, BUT I want to do it by a public slot that I created and which contains the close slot of the QWidget, instead of doing it using the default QWidget::close().…
Barbell
  • 194
  • 1
  • 6
  • 19
0
votes
1 answer

Qt signals and slots for QLineEdit

I have some trouble understanding how signal and slots work. I have an input and a button, I want a value to be written on the input field when I click the button. Please show me how it should be done. #include #include…
Barbell
  • 194
  • 1
  • 6
  • 19
0
votes
1 answer

Moving variables from one Qthread to another with pyqtsignal

I am building my first GUI in pyQT5 and I am pretty new to Python programming. I am trying to use a set a Variable in one Qthread and using it in another. I figured that pyqtsignal was the way to do it. But i can't get it to work. class…
0
votes
0 answers

Handling signals in client that reads continuously

I've implemented a TCP/IP client in Qt that reads data constantly (when reading function returns, it calls itself again). Now I need to handle a signal coming from another object, but the constant reading doesn't let the signal to be handled,…
JLev
  • 705
  • 1
  • 9
  • 30
0
votes
0 answers

Pass signals and data from a class to another on Qt

I will post the code first as it will be easier to understand after that. Basically, I have a default class, MainWindow: mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include #include…
caffeine
  • 435
  • 7
  • 26
0
votes
2 answers

Qt Change label text from another class

i'm trying to change the label text of Class A via Class B using Qt but i can't get it working, here's my codes: Class A: #include "mainwindow.h" #include "ui_mainwindow.h" #include "loldata.h" using namespace std; MainWindow::MainWindow(QWidget…
0
votes
1 answer

PyQt5 : How to make a button close the gui after clicking

Here is my code for the click button: run_btn=QtWidgets.QPushButton("Run") def main(): print ('Starting Program') run_btn.clicked.connect(main) But after I click "Run", it just prints "Starting Program" again and again, and the GUI window…
Itay Katsnelson
  • 69
  • 1
  • 2
  • 8
0
votes
1 answer

Same signals but to different buttons

I have 2 sets of 3 push buttons, each with a QDialogButtonBox() as follows: "Add" (AcceptRole) "Remove" (RejectRole) "Clear" (ResetRole) Something like that: self.set1_btns = QtGui.QDialogButtonBox() self.set1_btns.addButton("Add",…
dissidia
  • 1,531
  • 3
  • 23
  • 53
0
votes
1 answer

Qt Signal Slots class scope types

Given two headers from an external SDK, class A { public: class B { }; public slots: void onValue(B* b); }; class C { signal: void value(A::B* b); }; The question is how i can connect signal and slots of C -> A since the data…