Results 1 to 3 of 3

Thread: Detecting Enter in an editable QComboBox

  1. #1
    Join Date
    Nov 2009
    Posts
    20
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Detecting Enter in an editable QComboBox

    I have an editable QComboBox with an InsertAtCurrent insert policy. The trouble is that unless the user explicitly presses Enter, the new text the user has entered does not permanently change the text associated with the currentIndex. This makes sense actually but often times a user will enter the new text and simply left-click onto another widget, mistakenly assuming that the text they have just entered is set, only to find out later that it has not.

    Q1: Is there an easy way that I can detect when a user has left-clicked off of the QComboBox widget so that I can programmatically set the text entered by the user (and emulate an Enter command)?

    Q2: There is no editFinished signal available (by default) for the QComboBox widget. Can I create my own? If so, how?

    Thanks!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Detecting Enter in an editable QComboBox

    take a look at QComoBobx::lineEdit, but there is important note
    Qt Code:
    1. Only editable combo boxes have a line edit.
    To copy to clipboard, switch view to plain text mode 
    then if your combobox is editable you can simply catch lineedit's returnPressed or editingFinished signals.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following 3 users say thank you to spirit for this useful post:

    Eos Pengwern (6th January 2010), frankiefrank (16th August 2012), wconstan (28th December 2009)

  4. #3
    Join Date
    Nov 2009
    Posts
    20
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Talking Re: Detecting Enter in an editable QComboBox

    Worked like a charm Spirit! Thanks much for your help.

Similar Threads

  1. Editable QComboBox with QItemDelegate
    By Jmgr in forum Qt Programming
    Replies: 11
    Last Post: 10th December 2008, 10:21

Tags for this Thread

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.