Results 1 to 11 of 11

Thread: clicked() signal for QLineEdit

  1. #1
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default clicked() signal for QLineEdit

    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

  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: clicked() signal for QLineEdit

    Reimplement mouseReleaseEvent for your widget and emit the signal from within there. Why do you need such a signal anyway?

  3. #3
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: clicked() signal for QLineEdit

    my idea is that when I click on the QLineEdit, the text that is already show, disappear

  4. #4
    Join Date
    Apr 2008
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: clicked() signal for QLineEdit

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

  5. #5
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: clicked() signal for QLineEdit

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

  6. #6
    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: clicked() signal for QLineEdit

    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.

  7. #7
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: clicked() signal for QLineEdit

    gains focus will be the best, but isModified() how can be use as signal?

  8. #8
    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: clicked() signal for QLineEdit

    Not as a signal. Reimplement focusInEvent() and check whether isModified() is true. If not, clear the contents, otherwise leave it intact, that's all.

  9. #9
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: clicked() signal for QLineEdit

    U R GOD!!! hahahaha pretty good idea, thanks a lot

  10. #10
    Join Date
    Jun 2019
    Location
    Bangalore, India
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: clicked() signal for QLineEdit

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

  11. #11
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: clicked() signal for QLineEdit

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QTreeWidget clicked signal
    By ^NyAw^ in forum Qt Programming
    Replies: 41
    Last Post: 30th January 2010, 12:42
  2. disable clicked() signal
    By mattia in forum Newbie
    Replies: 2
    Last Post: 27th February 2008, 11:27
  3. QListWidget clicked signal
    By asieriko in forum Qt Programming
    Replies: 12
    Last Post: 10th August 2007, 16:37
  4. Custom Widget - clicked() signal
    By ak in forum Newbie
    Replies: 3
    Last Post: 13th November 2006, 09:35
  5. Replies: 10
    Last Post: 27th January 2006, 19:12

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.