cuốn sách gpt4 ai đã làm

python - 如何在不触发信号的情况下清除 QLineEdit

In lại Tác giả: Walker 123 更新时间:2023-11-28 21:53:39 25 4
mua khóa gpt4 Nike

QLineEdit hiện hữu .clear() hoặc .setText() 方法上触发信号。因此,每次使用这些方法来阻止 LineEdit 发出信号时,我都需要 .blockSignals(True) 然后是 .blockSignals(False)。我想知道是否有解决办法?

from PyQt4 import QtCore, QtGui    
app = QtGui.QApplication([])

class LineEdit(QtGui.QLineEdit):
def __init__(self, *args, **kwargs):
super(LineEdit, self).__init__()
self.setText('Some Text')
self.textChanged.connect(self.printMessage)
self.show()
def printMessage(self):
print 'Triggered!'

line=LineEdit()
line.clear()
sys.exit(app.exec_())

câu trả lời hay nhất

你有没有考虑过QLineEdit::textEdited?当以编程方式更改文本时,它不会发出信号。

关于python - 如何在不触发信号的情况下清除 QLineEdit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25777162/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress