Results 1 to 4 of 4

Thread: get mousepress when widget is disabled (QLineEdit)

  1. #1
    Join Date
    Aug 2010
    Location
    Germany
    Posts
    54
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question get mousepress when widget is disabled (QLineEdit)

    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)?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: get mousepress when widget is disabled (QLineEdit)

    Quote Originally Posted by mortoray View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    mortoray (26th October 2010)

  4. #3
    Join Date
    Aug 2010
    Location
    Germany
    Posts
    54
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: get mousepress when widget is disabled (QLineEdit)

    Quote Originally Posted by wysota View Post
    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.

  5. #4
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: get mousepress when widget is disabled (QLineEdit)

    Hi, can you post the code part which u used for the reimplementing the event() function?
    I'm having the same problem.

Similar Threads

  1. mousepress event
    By tpthyd in forum Qt Programming
    Replies: 3
    Last Post: 15th May 2009, 21:16
  2. mousepress event
    By tpthyd in forum Qt Programming
    Replies: 1
    Last Post: 25th February 2009, 15:02
  3. Can Qt4 capture mousePress events on the desktop?
    By simula in forum Qt Programming
    Replies: 5
    Last Post: 6th January 2009, 19:10
  4. setCursor & a disabled Widget
    By FoX_*D i E* in forum Qt Programming
    Replies: 3
    Last Post: 16th September 2008, 10:27
  5. MousePress Events on ContextMenu items
    By Naveen in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2006, 07:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.