Search code examples
pythonpython-3.4pyqt5qlineedit

PyQt5 how to set QLineEdit behaviour like '\n'


The answer is probably really simple but I searched like 30 mins and couldn't find anything. I just want to set QLineEdit like what does \n do. To be more specific, when I start to type in QLineEdit, if it's a long sentence and bigger than the width of QLineEdit, it's going straight like forever. I want to start it on a new line when the text is reach end of the QLineEdit box. Even I press enter while typing, it does not go to a new line. How can I fix this? Is QLineEdit only 1 row and doesn't go bottom line?


Solution

  • The "Line" is right there in its name, so yes, it supports "only 1 row".

    The QLineEdit widget is a one-line text editor.

    What you want is QPlainTextEdit or QTextEdit if you need styling.