Answer the question
In order to leave comments, you need to log in
PyQt exchange data between modules
There is a module generated via pyuic4 with the Ui_DockWidget class. It has a QTextEdit. Several functions have been added to the same class that insert text into textEdit. For example, the function
def textadd(self):
self.textEdit.setText("TEXT1")
app = QtGui.QApplication
mw = app.activeWindow()
editor= QtGui.QDockWidget()
editor.ui = mymodule.Ui_DockWidget()
editor.ui.setupUi(editor)
mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, editor)
Answer the question
In order to leave comments, you need to log in
It worked as a result of the following actions:
1.Created signal class
2. Declared a global variable of type QWidget.
3. TextEdit is passed to the global variable.
4. + a function that adds text to edit, eg myglobalvar.append('text')
5. + a function that calls a signal by passing function (4) to it in the slot and then emits.
mysignal.connect(textadd)
mysignal.emit()
As a result, text can be added from another module by calling the function in which the signal is connected.
What are the problems with this solution? That is, it works, but maybe something should not be done?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question