Answer the question
In order to leave comments, you need to log in
How to make a signal handler in PyQt5?
I have such a problem - signal handlers do not work correctly, they display an error.
The code:
class app(Ui_Form):
def __init__(self,parent):
Ui_Form.__init__(self)
self._connectSlots()
def _connectSlots(self):
Ui_Form.pushButton.clicked.connect(self.lineedit, self._slotAddClicked)
def _slotAddClicked(self):
text = self.lineedit.text()
if len(text):
lvi = QTableViewItem(self.tableview)
lvi.setText(0,text)
self.lineedit.clear()
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.tableView = QtWidgets.QTableView(Form)
self.tableView.setGeometry(QtCore.QRect(10, 10, 381, 251))
self.tableView.setObjectName("tableView")
self.lineEdit = QtWidgets.QLineEdit(Form)
self.lineEdit.setGeometry(QtCore.QRect(10, 270, 301, 20))
self.lineEdit.setObjectName("lineEdit")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(320, 270, 75, 23))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.lineEdit.setText(_translate("Form", "USER */%/# +n/-n"))
self.pushButton.setText(_translate("Form", "OK"))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question