python - 禁用编辑 QLineEdit

标签 python python-3.x pyqt pyqt5

我想在某些条件下,不可能编辑 QLineEdit 小部件。理想情况下,它看起来像:

QLE_On = QCheckBox("Non-editable?")
generic = QLineEdit()

if QLE_On.isChecked():
#disable editing of generic

查看文档,.isReadOnly 可能是实现我正在寻找的目标的一种可能选择,但我不太确定如何实现它。

最佳答案

只需将 lineEdit 设置为 False 即可使其不可编辑:

self.lineEdit.setEnabled(False)

关于python - 禁用编辑 QLineEdit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45248014/

相关文章:

python - SqlAlchemy 没有定义这样的多态身份

python - 尝试将输入到条目小部件中的文本存储到变量中

修改字典列表的 Pythonic 方法

Python - 使用 PyQt 进行线程处理

c++ - 在 Python 中制作 Qt/C++ 原型(prototype)

Python sys.excepthook 仅适用于主进程但不适用于子进程

Python:如何将 ARGV 参数传递给另一个脚本?

python - Tensorflow 成对自定义互信息损失

python - 比较两个数据帧并出现错误

python - 仅来自 Qt5 ColorDialog 的颜色渐变