Results 1 to 6 of 6

Thread: Complex editor in delegate

  1. #1
    Join Date
    Sep 2014
    Location
    France
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Complex editor in delegate

    Hello everyone.

    I have a problem with complex editors created by a delegate to edit field of QTreeView.

    The editor contain a QLabel (hidden in this case), a QLineEdit and a QPushButton.
    I managed to gave focus to the QLineEdit at editor creation with setFocusProxy(ui.lineEdit)

    My remaining problem is when the QLineEdit looses focus (on clic in another part of the application), the editor is not closed, and so the setModelData not called.
    The only way to close the editor is to change the current item selected in the TreeView.

    I can't figure out where it comes from.

    Thanks for your help !

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Complex editor in delegate

    Your delegate can emit the closeEditor() signal when it wants to let the view know that the editor should no longer be active.

    Cheers,
    _

  3. #3
    Join Date
    Sep 2014
    Location
    France
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Complex editor in delegate

    Yes but when ?

    I tried to installEventFilter on my widget, and on focusOut emit closeEditor() but it does not work.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Complex editor in delegate

    Does not work in the sense that the event filter does not get called or that emitting the signal does not work?

    Cheers,
    _

  5. #5
    Join Date
    Sep 2014
    Location
    France
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Complex editor in delegate

    The eventFilter is called, but never with an event Type FocusOut.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Complex editor in delegate

    Ah, ok, this is very strange.

    A couple of things you could try:
    - QLineEdit::editingFinished(): that signal is also emitted when the line edit loses focus
    - QApplication::focusChanged()

    Cheers,
    _

Similar Threads

  1. How to simplify a complex item delegate?
    By Adam Badura in forum Qt Programming
    Replies: 34
    Last Post: 23rd March 2013, 15:21
  2. Custom editor-delegate communication
    By AlexVhr in forum Newbie
    Replies: 10
    Last Post: 30th January 2013, 12:42
  3. Item Delegate editor background
    By LynneV in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2010, 22:33
  4. Delegate and editor hide event
    By zuck in forum Qt Programming
    Replies: 1
    Last Post: 1st November 2009, 18:59
  5. Delegate editor sizing problem
    By smacchia in forum Qt Programming
    Replies: 19
    Last Post: 7th December 2007, 17:27

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.