Feb-19-2024, 09:30 PM
That works with PySide6
import sys from PySide6.QtWidgets import QMainWindow, QApplication, QWidget, QLineEdit from PySide6.QtCore import Slot class MyMainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("Qt window") self.setMinimumSize(800,600) # widget of central area centralArea = QWidget() centralArea.setStyleSheet("background: #5A5E6B") self.setCentralWidget(centralArea) # textbox implementation textBox1 = QLineEdit("", centralArea) textBox1.setStyleSheet('background: lightgrey;' 'color: red;') textBox1.setGeometry(200, 90, 270, 30) textBox1.textEdited.connect(self.getTextInTextBox) # signal = "textEdited" # my own slot = "getTextInTextBox" # slots definition @Slot(str) def getTextInTextBox(self, text): print(f"Text in the textbox is '{text}'") return text if __name__ == "__main__": app = QApplication(sys.argv) MyWindow = MyMainWindow() MyWindow.show() implementedText = MyWindow.getTextInTextBox("") sys.exit(app.exec())