signals-slots

PyQt5 - TypeError: signal has 0 argument(s) but 1 provided

寵の児 提交于 2020-01-30 03:28:27
问题 I am trying to redirect "sys.stdout" to QTextEdit , here is my code: class Communicate(QObject): printText = pyqtSignal() def write(self, text): self.printText.emit(str(text)) class UI(QWidget): def __init__(self, parent = None): QWidget.__init__(self) ... self.textedit = QTextEdit(self) self.textedit.setGeometry(400,20,220,300) self.c = Communicate() self.c.printText.connect(self.textedit.insertPlainText) sys.stdout = self.c if __name__ == "__main__": ... When I ran the code, I got TypeError

PyQt5 - TypeError: signal has 0 argument(s) but 1 provided

独自空忆成欢 提交于 2020-01-30 03:28:09
问题 I am trying to redirect "sys.stdout" to QTextEdit , here is my code: class Communicate(QObject): printText = pyqtSignal() def write(self, text): self.printText.emit(str(text)) class UI(QWidget): def __init__(self, parent = None): QWidget.__init__(self) ... self.textedit = QTextEdit(self) self.textedit.setGeometry(400,20,220,300) self.c = Communicate() self.c.printText.connect(self.textedit.insertPlainText) sys.stdout = self.c if __name__ == "__main__": ... When I ran the code, I got TypeError

Can Qt signals return a value?

时光总嘲笑我的痴心妄想 提交于 2020-01-19 03:17:29
问题 Boost.Signals allows various strategies of using the return values of slots to form the return value of the signal. E.g. adding them, forming a vector out of them, or returning the last one. The common wisdom (expressed in the Qt documentation [EDIT: as well as some answers to this question ] ) is that no such thing is possible with Qt signals. However, when I run the moc on the following class definition: class Object : public QObject { Q_OBJECT public: explicit Object( QObject * parent=0 )

QT Connect Signal Slot and initialize in constructor

痞子三分冷 提交于 2020-01-17 02:58:07
问题 I create connections between widged in the constructor and also initialize them. But the connect not working (inside the methode). Code says alot: MyApp::MyApp(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); // slider to spinbox connect(ui.slider, SIGNAL(valueChanged(int)), ui.spinbox, SLOT(setValue(int))); // SIGNAL To SLOT not called ui.slider->setValue(2); // I have to set this also: ui.spinbox->setValue(2); } 回答1: Have you tried doing connect(ui.slider, SIGNAL(valueChanged(int)

PySide/PyQT5: How to emit signals from a QGraphicsItem?

妖精的绣舞 提交于 2020-01-15 09:20:28
问题 I want to emit a signal from a QGraphicsItem when it is doubled-clicked, in order to change a widget in the main window. The graphics-scene/-item does not provide an emit() method, but I was just wondering if there is an alternate way to do this. The code below has a function within a QGraphicsView class that will print to the terminal when an item is double-clicked. How can I make that into a slot/signal instead (if QGraphicsItem does not support signal/slots)? import sys from PySide.QtCore

PySide: How Could I trigger the current clicked QPushbutton, not other later added

南笙酒味 提交于 2020-01-13 07:12:32
问题 I am new to PySide. In my program, I encountered a problem that when I click one button, it triggers other button later added. Thanks! self.addContentButton = QtGui.QPushButton('Add') self.addContentButton.clicked.connect(self.addContent) def addContent(self): ''' slot to add a row that include a lineedit, combobox, two buttons ''' self.contentTabHBoxWdgt = QtGui.QWidget() self.contentName = QtGui.QLineEdit('line edit') self.conetentTypeBox = QtGui.QComboBox() self.conetentTypeBox.addItem(

PyQt_PyObject equivalent when using new-style signals/slots?

前提是你 提交于 2020-01-12 17:31:31
问题 So I have a need to pass around a numpy array in my PyQt Application. I first tried using the new-style signals/slots, defining my signal with: newChunkToProcess = pyqtSignal(np.array()) , however this gives the error: TypeError: Required argument 'object' (pos 1) not found I have worked out how to do this with the old-style signals and slots using self.emit(SIGNAL("newChunkToProcess(PyQt_PyObject)"), np.array([5,1,2])) - (yes, that's just testing data :), but I was wondering, is it possible

PyQt_PyObject equivalent when using new-style signals/slots?

偶尔善良 提交于 2020-01-12 17:30:02
问题 So I have a need to pass around a numpy array in my PyQt Application. I first tried using the new-style signals/slots, defining my signal with: newChunkToProcess = pyqtSignal(np.array()) , however this gives the error: TypeError: Required argument 'object' (pos 1) not found I have worked out how to do this with the old-style signals and slots using self.emit(SIGNAL("newChunkToProcess(PyQt_PyObject)"), np.array([5,1,2])) - (yes, that's just testing data :), but I was wondering, is it possible

PySide: Returning a value from a slot

心已入冬 提交于 2020-01-11 09:35:15
问题 The Pyside documentation states that slots can have return values, but I have yet to figure out how make it do so. I couldn't find any usable code samples on this, so I've added a decorator as the docs suggest: def testSlot(self): print('testSlot called') return 'RETURN VALUE RETURN VALUE RETURN VALUE' And I'm trying to capture the return value like this: ret = foo.testSignal.emit() But it's not working. My test code, which you can find here, also crashes with this error output. Help is

How does boost implements signals and slots?

孤人 提交于 2020-01-11 04:19:25
问题 To continue another question, lets ask this: How does Boost implement the signals/slot mechanism? See: How signal and slots are implemented under the hood? http://www.boost.org/doc/libs/1_40_0/doc/html/signals.html 回答1: here's an interesting snippet from this gamedev.net thread to get the discussion rolling Original post by Spoonbender So, bonus question: What causes boost::signals to be that much slower? It looks like there are a couple of biggies. First, despite the fact that boost::signals