Results 1 to 3 of 3

Thread: Closing QCompleter when QLineEdit loses focus

  1. #1
    Join Date
    Jan 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Closing QCompleter when QLineEdit loses focus

    Hi,

    I have a QLineEdit on which I set a QCompleter in popup mode, to edit an item in a QTableView. I'd like the editing to start on the next item when I press the tab key. This works fine if I first close the completer, by either clicking on it or pressing return, but not when the QLineEdit simply loses focus.

    Would someone have a workaround ? (BTW, this works fine with CurrentChanged edit trigger set... but I don't like it.)

    Thanks,
    Mathieu

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Closing QCompleter when QLineEdit loses focus

    You can re implement focusOutEvent()...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Closing QCompleter when QLineEdit loses focus

    Thanks high_flyer, but it seems the view closes each editor before the QLineEdit is destroyed...

    So, I simply implemented a slot in the view, e.g. lineEditDestroyed() and connected it to the destroyed() signal of the QLineEdit. I this slot, I manually call edit() on the current index.

Similar Threads

  1. Replies: 4
    Last Post: 21st January 2011, 02:27
  2. Replies: 1
    Last Post: 12th January 2011, 23:40
  3. QLineEdit + QCompleter: returnPressed signal
    By thefriedc in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2010, 17:21
  4. QCompleter causes table to lose focus
    By knack in forum Qt Programming
    Replies: 3
    Last Post: 29th August 2010, 23:22
  5. QWinwidget loses focus
    By salix in forum Qt Programming
    Replies: 0
    Last Post: 16th June 2009, 22:54

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.