qt-signals

PyQt5 Signals and Slots 'QObject has no attribute' error

南楼画角 提交于 2019-11-29 02:21:51
I have been trying to find a way to update the GUI thread from a Python thread outside of main. The PyQt5 docs on sourceforge have good instructions on how to do this. But I still can't get things to work. Is there a good way to explain the following output from an interactive session? Shouldn't there be a way to call the emit method on these objects? >>> from PyQt5.QtCore import QObject, pyqtSignal >>> obj = QObject() >>> sig = pyqtSignal() >>> obj.emit(sig) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'QObject' object has no attribute 'emit' and >>>

Qt signals and slots: permissions

安稳与你 提交于 2019-11-28 20:25:08
There are discrepancies between respected answers here on SO and the actual Qt docs. I've read this question and I want some further clarification. Can anyone confirm: A signal is always protected , therefore it can be emitted only by the class or any of its subclasses. I'm not sure this is true; the question above shows answers supporting this statement. But the Qt docs say: Signals are public access functions and can be emitted from anywhere, but we recommend to only emit them from the class that defines the signal and its subclasses. So which is it? Slots are just functions, and thus may be

private/public qt signals

好久不见. 提交于 2019-11-28 10:40:42
Can Qt signals be public or private? Can I create internal signals, which are seen only inside the class? Update: I have a class with some internal signals. How can I make those signals invisible for other classes (encapsulation & information hiding)? Andrei Vlasyuk No. Signals cannot be public or private. Qt signals are protected class methods. "signals" keyword is defined in qobjectdefs.h (line 69 as for Qt 4.6.1): # define signals protected UPDATE: signals are only protected upto and including all minor versions of Qt 4. From Qt 5.0 onwards they are public . See https://stackoverflow.com/a

QMetaObject::invokeMethod doesn't find methods with parameters

跟風遠走 提交于 2019-11-28 07:46:31
问题 This is a follow up of QMetaObject::invokeMethod doesn't find the method. Invoking a method without paramters works. But extending the previous question to methods with parameters brings me back to failure again. See the following example script in Python: from PySide import QtCore class Example(QtCore.QObject): def __init__(self): super().__init__() @QtCore.Slot() def dup(self): beep('dup-class') @QtCore.Slot(str) def beep(self, text): print(text) @QtCore.Slot() def dup(self): beep('dup

Qt 5 : update QProgressBar during QThread work via signal

限于喜欢 提交于 2019-11-28 02:14:34
问题 I'm trying to update a QProgressDialog (owned by a QMainWindow class) along the execution of a QThread who process some time consuming operations. The thread emit some signals during operation in order to inform the calling app about progression. I'm looking to connect the progress signal emitted by the thread to the setValue slot of the QProgressDialog in order to update the progress bar. It doesn't work ! The progress dialog is not displayed. If I add a slot in my QMainWindow and connect it

waiting for a signal

荒凉一梦 提交于 2019-11-27 23:43:45
I am working on an application which uploads the content of the file to server. To upload the file to server I am using ‘QNetworkAccessManager’ class. Since it works as asynchronous way, I changed it to work as synchronous way by using QEventLoop. Class FileTransfer { Public : QNetworkAccessManager mNetworkManager; Void Upload(QNetworkRequest request, QIODevice *data) { responce = mNetworkManager.put(request, data); EventLoop.exec(); ReadResponce(responce); } Void Stop() { responce ->close(); } } In my sample application I have 2 windows. 1st to select the files and 2nd to show the progress.

QObject connection function

情到浓时终转凉″ 提交于 2019-11-27 23:29:24
I checked other similar questions and tried their solutions but they don't work for me. I'm basically trying to make a http client that only makes post requests. In order to do this, I need to connect QNetworkManager 's finished signal to some callback slot. Here's my code. h file : ... public slots: void finishedSlot(QNetworkReply* reply); private: QNetworkAccessManager *network_manager; ... cpp file : ... Class1::Class1(){ network_manager = new QNetworkAccessManager(this); QObject::connect(network_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(finishedSlot(QNetworkReply *))); } ...

Qt signals and slots: permissions

萝らか妹 提交于 2019-11-27 20:30:29
问题 There are discrepancies between respected answers here on SO and the actual Qt docs. I've read this question and I want some further clarification. Can anyone confirm: A signal is always protected , therefore it can be emitted only by the class or any of its subclasses. I'm not sure this is true; the question above shows answers supporting this statement. But the Qt docs say: Signals are public access functions and can be emitted from anywhere, but we recommend to only emit them from the

Are signals in Qt automatically disconnected when one of the class is deleted

有些话、适合烂在心里 提交于 2019-11-27 17:06:24
问题 Does Qt automatically remove connections between objects , when one of the side is deleted ? e.g connect (A .. , B ..) , when A (a pointer) is deleted , or B is deleted , will the connection be disconnected ? Is it necessary to use disconnect explicitly in destructor ? 回答1: Yes, the QObject::~QObject destructor takes care of that: All signals to and from the object are automatically disconnected, and any pending posted events for the object are removed from the event queue. However, it is

PyQt5 Signals and Slots 'QObject has no attribute' error

泪湿孤枕 提交于 2019-11-27 16:49:26
问题 I have been trying to find a way to update the GUI thread from a Python thread outside of main. The PyQt5 docs on sourceforge have good instructions on how to do this. But I still can't get things to work. Is there a good way to explain the following output from an interactive session? Shouldn't there be a way to call the emit method on these objects? >>> from PyQt5.QtCore import QObject, pyqtSignal >>> obj = QObject() >>> sig = pyqtSignal() >>> obj.emit(sig) Traceback (most recent call last)