I'm trying to get the text of a veriable from a class A, and use the text of it in a QLineEdit
to show it every time that the text changes in the variable.
Something like this:
class A(self):
variable = None
def __init__(self):
pass
def get_text(self):
self.variable = "Hello" #Every time that this value changes, it must be shown in the QLineEdit
class B(self):
def __init__(self):
pass
def show_text(self):
qle = QLineEdit()
qle.setText(A.variable)
What i am trying to do is get the coordinates of the mouse, set them as str
and show them in a QLineEdit
in a QDialog
that i created in QtDesigner
How can i accomplish this? Hope you can help me.
EDIT
I need class B
to be a QDialog
. I added some changes to make it more readable for what i need.
class A(QMainWindow):
def __init__(self):
pass
def get_text(self, event):
if event.button == 1:
self.variable = event.xdata
@property
def variable(self):
self.b.qle.setText()
@variable.setter
def variable(self, value):
self.b.qle.setText(value)
class B(QDialog):
def __init__(self, parent):
QDialog.__init__(self, None)
# you need to store the lineedit as a instance attribute of B so it can be accessed in A
self.qle = QLineEdit()
Is there anything that i am missing?