PDA

View Full Version : QLineEdit: textEdited called on backspace



akiross
10th August 2011, 20:00
Hello,
from the manual of QLineEdit
textEdit():

This signal is emitted whenever the text is edited. The text argument is the next text.
Unlike textChanged(), this signal is not emitted when the text is changed programmatically, for example, by calling setText().

But still this signal seems to be called when using the backspace() (or del()) method.

How come? If the difference is only on setText(), then what's the point of having two methods, since I've to do everything by hand?

Thanks in advance :)
~Aki

mvuori
11th August 2011, 09:50
I think Qt's approach makes sense. When you use backspace() in your app, you are editing the field programmatically and may need to callback to check what is happening. But the situation is different when you get the text in a string, edit it with any functions needed and return the whole string back (perhaps changed, perhaps replaced). In that case it is "changed", but not "edited".

akiross
14th August 2011, 22:47
Hi, thanks for the reply!
I'm not sure I got your point...
Why using "changed" and not "edited" if only *some* functions affect the behavior, while others don't?
I mean, we could also use only one signal "changed", and keep track of what we are doing programmatically; having an "edited" signal (which signals only changes by the user), is a convenient way of tracking what user is doing and. But if both signals are emitted some times, while some other times only one signal is emitted, then where's the convenience?

Anyway, I'm not sure if just asking "why" is useful... As "programmatically" on the doc doesn't seems to be always honored, it would be useful to know which methods emit which signal.

Thanks again
~Aki