'Every time the button is pressed, I want the onClicked function to work and increase the x, y, z values, but it always returns 0. How can I solve this problem? Where am I making mistakes?'
global x,y,z
x = 0
y = 0
z = 0
class main2(QMainWindow):
def __init__(self, x, y, z):
super(main2, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.x= x
self.y= y
self.z= z
self.ui.btnCount.clicked.connect(self.onClicked)
def onClicked(self):
self.x += 1
self.y += 1
self.z += 1
print(x, y, z)
return x, y, z
def main():
app = QApplication(sys.argv)
win = main2(x, y, z)
win.show()
sys.exit(app.exec_())
main()