[英]PyQt bug with QLIneEdit
When QLineEdit() is used in text it appears to create a bug in lists and dictionaries,this code works: 当在文本中使用QLineEdit()时,它似乎在列表和词典中创建了一个错误,此代码有效:
from PyQt5.QtWidgets import *
a=[1,2]
b=a[0]
print(b)
but when a line edit is added python will crash 但是当添加行编辑时,python将崩溃
from PyQt5.QtWidgets import *
c=QLineEdit()
a=[1,2]
b=a[0]
print(b)
I have found this when using the Anaconda package on multiple computers, can anyone suggest a work around which does not involve not using lists or dictionaries. 我在多台计算机上使用Anaconda软件包时发现了这一点,任何人都可以提出一种不涉及不使用列表或字典的解决方法。
You use it in wrong way. 您以错误的方式使用它。 First you have to use
QApplication(sys.argv)
which initiates all needed modules and librares. 首先,您必须使用
QApplication(sys.argv)
来初始化所有需要的模块和库。
from PyQt5.QtWidgets import *
import sys
app = QApplication(sys.argv)
c = QLineEdit()
a = [1,2]
b = a[0]
print(b)
So find some PyQt5 tutorial. 因此,找到一些PyQt5教程。
EDIT: problem is not list or dictionary but QListEdit
(or any other Widget) without QApplication
编辑:问题不是列表或字典,而是没有
QApplication
QListEdit
(或任何其他小部件)
You get the same problem in 您在遇到同样的问题
from PyQt5.QtWidgets import *
QLineEdit()
or 要么
from PyQt5.QtWidgets import *
QWidget()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.