Results 1 to 4 of 4

Thread: Use of QAbstractItemDelegate::closeEditor

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    33
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10
    Thanked 5 Times in 3 Posts

    Default Re: Use of QAbstractItemDelegate::closeEditor

    Quote Originally Posted by jacek View Post
    Maybe you should reimplement QItemDelegate::createEditor() instead and assign the validator to the editor there?
    The problem with that is that it still allows you to TAB to the next cell. It just doesn't store the data in the model. It doesn't provide any cursor control.

  2. #2
    Join Date
    Dec 2006
    Posts
    33
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10
    Thanked 5 Times in 3 Posts

    Thumbs up Re: Use of QAbstractItemDelegate::closeEditor

    Quote Originally Posted by jml View Post
    The problem with that is that it still allows you to TAB to the next cell. It just doesn't store the data in the model. It doesn't provide any cursor control.
    I finally solved the problem. QItemDelegate re-implements the virtual function eventFilter. So I just created a new class derived from QItemDelegate.
    In eventFilter, if it's not a TAB key:
    Qt Code:
    1. return QItemDelegate::eventFilter(editor, event);
    To copy to clipboard, switch view to plain text mode 
    If it is a TAB and validates OK:
    Qt Code:
    1. emit commitData(lineEdit);
    2. emit closeEditor(lineEdit, QAbstractItemDelegate::EditNextItem);
    3. return true;
    To copy to clipboard, switch view to plain text mode 
    If not:
    Qt Code:
    1. emit closeEditor(lineEdit, QAbstractItemDelegate::NoHint);
    2. return true
    To copy to clipboard, switch view to plain text mode 
    Jim L
    Seattle, WA

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

    jacek (4th August 2007), skuda (21st November 2007)

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
  •  
Qt is a trademark of The Qt Company.