Issue
I want to create my own very simple editor of .txt files. As in real editors, I want that if you change the file and don't save it yet, the name of file will start with '*' (for example, *some_text_file.txt).
I think that fot this I should check QPlainTextEdit after the file was downloaded to editor and after the user pushed button 'save'. But I don't know how to check QPlainTextEdit without user control, but after some changes. Or maybe there is another way to do it. So, how to do it?
Solution
You could use the textChanged
signal from the QPlainTextEdit
. It indicates when the input text has changed. See:
https://doc.qt.io/qt-5/qplaintextedit.html#textChanged
Roughly, you would do the following:
- load the file
- display the filename without asterisk
- connect the
textChanged
signal into a slot (function) that will add asterisk to the filename - when the Save button is pressed, remove the asterisk
If you're a Qt beginner, you might want to read about the Qt signal and slot mechanism:
https://doc.qt.io/qt-5/signalsandslots.html
Answered By - Jussi Nurminen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.