我遇到了无法从单独的类方法访问PyQT QTextEdits和QLineEdits的问题。我得到了该错误的不同变体:
AttributeError:类型对象'MyApp'没有属性'Ui_MainWindow'
我已经尝试了所有我能想到的,包括:
请在下面查看我的代码:
from app import Ui_MainWindow #import UI
class MyApp(QtWidgets.QMainWindow, Ui_MainWindow): #GUI class
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.button_search_item.clicked.connect(new_class.get_information)
class new_class(MyApp): #new class that i want to call on qtext and qline edits.
def get_information(self):
print(str(MyApp.Ui_MainWindow.setupUi.qlineedit_item.text()))
#OUTPUT:
#AttributeError: type object 'MyApp' has no attribute 'Ui_MainWindow'