qt-signals

How delete and deleteLater works with regards to signals and slots in Qt?

ⅰ亾dé卋堺 提交于 2019-11-26 15:12:36
There is an object of class QNetworkReply. There is a slot (in some other object) connected to its finished() signal. Signals are synchronous (the default ones). There is only one thread. At some moment of time I want to get rid of both of the objects. No more signals or anything from them. I want them gone. Well, I thought, I'll use delete obj1; delete obj2; But can I really? The specs for ~QObject say: Deleting a QObject while pending events are waiting to be delivered can cause a crash. What are the 'pending events'? Could that mean that while I'm calling my delete , there are already some

C++ Qt signal and slot not firing

独自空忆成欢 提交于 2019-11-26 08:57:25
问题 I am having difficulty in my Qt program with connecting button signals to my slots. My code is: Main.cpp #include <QtGui/QApplication> #include \"MainWidget.h\" int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWidget mainWidget; mainWidget.show(); return app.exec(); } MainWidget.h #ifndef MAINWIDGET_H #define MAINWIDGET_H #include <QWidget> class MainWidget : public QWidget { public: MainWidget(); public slots: void bAdvice_clicked(); void bWeather_clicked(); void

Declare abstract signal in interface class

ぃ、小莉子 提交于 2019-11-26 06:05:56
问题 How to declare a Qt signal in an abstract class / interface when the implementing class is already derrived from QObject/QWidget? class IEmitSomething { public: // this should be the signal known to others virtual void someThingHappened() = 0; } class ImplementEmitterOfSomething : public QWidget, public IEmitSomething { // signal implementation should be generated here signals: void someThingHappended(); } 回答1: As I found out in the last days... the Qt way of doing this is like this: class

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

谁说我不能喝 提交于 2019-11-26 04:28:21
问题 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 many people have my problem. I have applied their solutions, but my problem remains. for row in xrange(len(uniqueFields)): instance = QtGui.QCheckBox(uniqueFields[row], findInstance.tableWidget) print QtCore.QObject.connect(instance, QtCore.SIGNAL

How delete and deleteLater works with regards to signals and slots in Qt?

♀尐吖头ヾ 提交于 2019-11-26 04:19:06
问题 There is an object of class QNetworkReply. There is a slot (in some other object) connected to its finished() signal. Signals are synchronous (the default ones). There is only one thread. At some moment of time I want to get rid of both of the objects. No more signals or anything from them. I want them gone. Well, I thought, I\'ll use delete obj1; delete obj2; But can I really? The specs for ~QObject say: Deleting a QObject while pending events are waiting to be delivered can cause a crash.

My signal / slot connection does not work

久未见 提交于 2019-11-26 00:38:21
问题 I repeatedly see people having problems with slots not being called. I would like to collect some of the most common reasons. So maybe I can help people and avoid a lot of redundant questions. What are reasons for signal / slot connections not working? How can such problems be avoided? 回答1: There are some rules that make life with signals and slots easier and cover the most common reason for defective connections. If I forgot something please tell me. 1) Check the debug console output: When

Passing extra arguments through connect

若如初见. 提交于 2019-11-26 00:16:11
问题 Is it possible to pass variables through slots so I can print out certain text? Trying to pass variable \'DiffP\' which is defined in another function to slot. \'DiffP\' changes based on which file is selected. def addLineEdit(self): try: self.clearLayout() self.FileButton ={} self.Input = {} self.TotalInput = [] for i in range(int(self.numberLine.text())): self.FileButton[i] = QtWidgets.QPushButton(self.centralwidget) self.FileButton[i].setText(\'Case {}\'.format(i+1)) self.FileButton[i]