0

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)
ROM3K
  • 15
  • 3
  • Typo: remove the parentheses after `clear`: connections expect a reference to a callable, but you're actually *calling* it. – musicamante Feb 25 '23 at 23:38

1 Answers1

1

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

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

Misinahaiya
  • 502
  • 2
  • 17
  • Why? Well, you are connecting a *method*, but not a *slot*. You are connecting a **None** returned by the *method*. That will cause an error in PyQt, and a ignorance in PySide. Remove the bracket to found a *pointer* / *reference* to the slot. – Misinahaiya Feb 25 '23 at 23:44
  • Please don't use comment to add further information to the post: just [edit] it. That said, the question can be mostly considered as a typo (which is considered off topic), or, at least a duplicate (there are many, starting [from this](https://stackoverflow.com/q/40982518)). – musicamante Feb 28 '23 at 00:09