QTextEdit widget: Add close (x) button
Hello,
I am quite new in this area..
My main issue is how to add a close button (x) in the right up corner of the text editor in the same way as this button exists to a dialog etc. I need this button in order to close the text file which is currently displayed in the text editor or just "remove" the content of the text editor.
Thank you in advance.
Re: QTextEdit widget: Add close (x) button
Qt 5.2 introduced a clearButton property. Is this what you mean?
https://doc.qt.io/qt-5/qlineedit.htm...onEnabled-prop
1 Attachment(s)
Re: QTextEdit widget: Add close (x) button
The question concerns QTextEdit, not QLineEdit.
I would solve this problem by embedding the QTextEdit into a QWidget parent. Put a QVBoxLayout into the QWidget, then add a QHBoxLayout inside that. Add a QToolButton to the horizontal layout, and use a Horizontal spacer to push it to the right. Add your QTextEdit under the QHBoxLayout as the second item in the QVBoxLaout. See the screenshot below.
Attachment 12833