Results 1 to 2 of 2

Thread: QItemDelegate and default actions...

  1. #1
    Join Date
    Feb 2009
    Posts
    29
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QItemDelegate and default actions...

    I have a QTableWidget that uses a custom QItemDelegate derived object to handle cell edits. Also part of the UI are a series of buttons - 4 to move, and 3 to add/edit/remove data. The Add button has the auto-default property, and if I take it off it goes to another button.

    I have no problem with the Add button having the auto-default property, and it works well.

    My problem is that when a user edits a cell; if they hit 'enter' to accept their changes, it also triggers the default button. So the changes are saved, but the user also gets prompted to add another row of data. (And this can be quite annoying.)

    I'd really like it if they could just press enter to accept their changes and it would simply save the data in the delegate editor.

    Is there any way I can correct this?

    I discovered I can't send signals from within the QItemDelegate class as the functions (createEditor, setEditorData, setModelData) are all const functions. (Otherwise I could just send signals when the editor is created/destroyed to disable/enable the buttons to achieve the desired effect; but I'm not sure that would produce a 100% desired affect either.)

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QItemDelegate and default actions...

    Have a look at QAbstractItemDelegate::editorEvent and return true for enter pressed.

    Hope it might work

  3. The following user says thank you to aamer4yu for this useful post:

    TemporalBeing (11th June 2009)

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.