pythonqpushbuttonqlineeditpyside6

Python PySide 6 QLineEdit, PushButtons problems


I am new in PySide. Could someone tell me what is wrong with this code beacuse kolejny_btn cant clear the QLineEdit named osoby I dont know what to do I was seacrhing everywhere and I couldnt found this problem

Here is the code:

from PySide6.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox, QLineEdit, QLabel, QTextEdit
from PySide6.QtGui import QCloseEvent, QPixmap
import random
class LoginWindow(QWidget):

    def __init__(self):
        self.liczba_osob = None
        self.osoby = []
        super().__init__()
        self.setup()

        self.liczba_osob = (QLineEdit(self))
        self.liczba_osob.setFixedWidth(200)
        self.liczba_osob.move(100, 270)

        kolejny_btn = QPushButton("Kolejna osoba", self)
        kolejny_btn.move(160, 400)
        kolejny_btn.clicked.connect(self.liczba_osob.clear())

if __name__ == '__main__':
    app = QApplication([])

    login_window = LoginWindow()

    app.exec()
(It's not a full code beacuse I couldnt post full)

Solution

  • May you remove the round brackets <this one => ()> on your connection code?

    kolejny_btn.clicked.connect(self.liczba_osob.clear)