PDA

View Full Version : get mousepress when widget is disabled (QLineEdit)



mortoray
26th October 2010, 09:35
I have some disabled controls that I want to emit a signal when they are clicked. The typical use is a QLineEdit which in some modes can be edited, and in others not. Clicking on it when disabled gives the use a prompt which allows them to enable the editing.

How can I get a mouse press event when the control is disabled?

Alternately, how can I make it just look disabled (not just read-only)?

wysota
26th October 2010, 09:42
How can I get a mouse press event when the control is disabled?
Reimplement event() for the widget and handle the mouse event there.


Alternately, how can I make it just look disabled (not just read-only)?
Reimplement the paint event for the widget and change the style options passed to the style for drawing the widget.

A side note - from usability and user-friendliness perspective what you are trying to do is a very poor design. A much better approach would be to provide a checkbox near the line edit to enable or disable the widget.

mortoray
26th October 2010, 09:59
Reimplement event() for the widget and handle the mouse event there.

That works. Thank you.


A side note - from usability and user-friendliness perspective what you are trying to do is a very poor design. A much better approach would be to provide a checkbox near the line edit to enable or disable the widget.

Agreed. In fact a single checkbox for the whole interface is all that is needed "[x] Advanced Controls". But alas, my powers of persuasion have failed me. :(

madhukiranmp
10th November 2010, 04:44
Hi, can you post the code part which u used for the reimplementing the event() function?
I'm having the same problem.