I am instantiating an editable QLabel like so:
QLabel foo("some text");
foo.setTextInteractionFlags(Qt::TextEditorInteraction);
I can click the text and modify it, and the modified text must be in a buffer somewhere, but even after examining the data fields in Qt Creator I don't see where it is:
QString notmodified = foo.text(); // only returns the original text
is the modified text somewhere that I can access it?
EDIT: I think using something开发者_开发技巧 else is indeed an easier way, but I'm still interested in knowing the answer to my question.
EDIT: OK, it's been a week. "Answered".
I would say that even though you can set this flag on a QLabel
(the Qt::TextInteractionFlag
is used by other widgets than QLabel
), it is not designed to be edited.
Why don't you use a QLineEdit
?
For editable text field you have a good choise, QLineEdit or QTextEdit. Use one of these widgets. QLabel is just for labeling.
精彩评论