PDA

View Full Version : clicked() signal for QLineEdit



smarinr
25th July 2008, 18:16
Hi,
does anybody knows how to implement a signal that when I clicked on a QLineEdit? I really appreciate because I already eated the API from top to botttom

wysota
25th July 2008, 18:17
Reimplement mouseReleaseEvent for your widget and emit the signal from within there. Why do you need such a signal anyway?

smarinr
25th July 2008, 18:20
my idea is that when I click on the QLineEdit, the text that is already show, disappear

fifth
25th July 2008, 18:38
my idea is that when I click on the QLineEdit, the text that is already show, disappear

This would mean your widget behaves inconsistently when receiving focus with Tab or with a click.

Not sure exactly what your trying to achieve but sounds like it might be better to put your code into a focus event method.

smarinr
25th July 2008, 18:41
This would mean your widget behaves inconsistently when receiving focus with Tab or with a click.

Not sure exactly what your trying to achieve but sounds like it might be better to put your code into a focus event method.

let me explain better: when you click the QLineEdit, the text that is already in disappear but if nothing change so the text that was already there, still there

wysota
25th July 2008, 19:20
Well.. it really depends how you want it to behave. Do you actually want it only to happen when clicking or when the widget gains focus. As for actual implementation, use the "modified" property of the line edit to see if the text was changed by the user.

smarinr
25th July 2008, 19:23
gains focus will be the best, but isModified() how can be use as signal?

wysota
25th July 2008, 19:27
Not as a signal. Reimplement focusInEvent() and check whether isModified() is true. If not, clear the contents, otherwise leave it intact, that's all.

smarinr
25th July 2008, 19:35
U R GOD!!! hahahaha pretty good idea, thanks a lot

pkthapa
26th June 2019, 06:07
Not as a signal. Reimplement focusInEvent() and check whether isModified() is true. If not, clear the contents, otherwise leave it intact, that's all.

I have readOnly flag as true for QLineEdit. The focusIn and focusOut event do not work when readOnly is true.
Can you please help me out with this?

d_stranz
26th June 2019, 16:35
I have readOnly flag as true for QLineEdit.

If readOnly is true, then by definition the text cannot be edited by the user and the widget will never receive focus. Receiving / losing focus means the widget can interact with the user, which is not possible for a readOnly QLineEdit. In this case, the QLineEdit is not much different from a QLabel. If you want the widget to behave like a normal QLineEdit, then do not set the readOnly flag.