signals-slots

How to send None with Signals across threads?

对着背影说爱祢 提交于 2019-12-10 23:41:12
问题 I've implemented a version of the worker pattern that is described in the Qt Threading docs. I'm using Signals/Slots to send data between the worker thread and the main thread. When defining the Signal , I've set the argument signature type to object since I believe it should allow me to pass any python object through the Signal . result_ready = QtCore.Signal(object) However, when I try to pass None through the Signal it crashes python. This only happens when trying to pass the Signal across

Does PyQT4 signal.connect keep objects live?

左心房为你撑大大i 提交于 2019-12-10 19:13:52
问题 If I have a signal and I register an objects function to the signal will this keep the object live and stop the garbage collection of that object? E.g. class Signals(): signal = Qt.pyqtSignal() def __init__(self): QObject.__init__(self) class Test(); def __init__(self, s): s.connect(self.done) def done(self): print("Done") s = Signals() t = Test(s.signal) t = None s.signal.emit() Will the Test objecct still get the signal? 回答1: No, it won't, it's not enough to keep the object alive. Just try

How to know that a file was opened ? QT

我的梦境 提交于 2019-12-10 17:47:40
问题 I want to know if a file was opened by user for reading (double click or open with ...), I am coding a C++ application with Qt Creator on Windows, after some research I found QFileSystemWatche, but it let me know only if a change was happened in the specific folder. void QFileSystemWatcher::fileChanged ( const QString & path ) [signal] This signal is emitted when the file at the specified path is modified, renamed or removed from disk. How to know if the file was opened? or is there a way to

Qt: some slots don't get executed in release mode

守給你的承諾、 提交于 2019-12-10 17:24:27
问题 I am doing some simple program in Qt (MSVC++2008) with few checkboxes and buttons. In debug mode, everything works fine, but I can't distribute such executable, because most people don't have Visual Studio installed. When I do compile it in release mode, only 2 pushbuttons work. I have designed my window using Qt Creator's 'drawing tool' (Qt Designer, I guess). I do have such slots defined in my header file: private slots: void on_goButton_clicked(); // Works fine void on_InputCheckBox

Disconnect and later reconnect a Qt signal

感情迁移 提交于 2019-12-10 16:40:06
问题 Is there a way to disconnect a Qt signal only temporarily, but store a list of the objects connected to it, so the signal can later be reconnected to them? 回答1: http://qt-project.org/forums/viewthread/6820 This post discusses ways to keep track of the list of connections to a particular signal which could be used for reconnecting it after disconnect is called. 来源: https://stackoverflow.com/questions/14144415/disconnect-and-later-reconnect-a-qt-signal

PyQt5 + Python 3: passing lists, dicts as signal arguments across threads

这一生的挚爱 提交于 2019-12-10 15:56:30
问题 I am using pyqtSignal to send a python list as an argument from worker thread to main thread. When does qt create a copy of the object being passed as argument. According to: http://www.embeddeduse.com/2013/06/29/copied-or-not-copied-arguments-signals-slots/ the qt should make a copy of the object. However, in the example below the main thread can change the contents of the list being sent from another thread. import sys import time from PyQt5.QtCore import QThread, QObject, pyqtSlot,

Qt Signals and slots - No matching function for call

∥☆過路亽.° 提交于 2019-12-10 15:51:07
问题 I am learning QT and am trying to get my signals and slots working. I am having no luck. Here is my Main int main(int argc, char** argv) { QApplication app(argc, argv); FilmInput fi; FilmWriter fw; QObject::connect (&fi->okButton, SIGNAL( clicked() ), &fi, SLOT( okButtonClicked() ) ); //Error received Base operand of '->' has non-pointer type 'FilmInput' QObject::connect(&fi,SIGNAL(obtainFilmData(QVariant*)),&fw,SLOT(saveFilmData(QVariant*))); //Error received No matching function for call to

Qt - arguments in signal-slots

社会主义新天地 提交于 2019-12-10 15:44:42
问题 I have a QPushButton, QDateEdit and another custom object. I want to connect the button to the date edit object in a way that when I click the button, the date edit object will change its set date to a date defined on the custom object. Kinda like this: connect(pushbutton,SIGNAL(clicked()),dateedit,SLOT(setDate(custom_object.getDate()))); but I can't do that. Apparently, the connect statement doesn't specify what's the information being passed from the signal to the slot, only the type of the

Are “public slots:” sections still necessary in Qt5?

扶醉桌前 提交于 2019-12-10 13:03:54
问题 A simple question regarding the new signal/slot syntax in Qt5: Are there still benefits for a Q_OBJECT -derived class to have public slots: sections declared? Note: With the new syntax you're able to connect a signal to any public function of a class or directly implement a C++11 lambda (which can also call some member functions itself). Qt's new signal/slot syntax 回答1: While the answers by vahancho and TheDarkKnight are valid: slots is not required for connections, but it makes the intent

How to perform action on clicking a QMenu object only?

好久不见. 提交于 2019-12-10 10:23:11
问题 Here's a snapshot of the GUI. I want to perform simple actions solely by clicking on QMenu object Help. This QMenu object does NOT have any submenus. Can you please advise me how to perform actions when only the QMenu is clicked Here's what I have tried, but I got an empty output. mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QDebug> #include <QSignalMapper> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: