Results 1 to 4 of 4

Thread: Check what EditTrigger triggered the QStyledItemDelegate

  1. #1
    Join Date
    Mar 2011
    Posts
    15
    Thanks
    4
    Qt products
    Qt4

    Default Check what EditTrigger triggered the QStyledItemDelegate

    I have a custom delegate class that inherits from QStyledItemDelegate.
    Is it possible to know in createEditor() of the delegate, what action triggered the delegate?
    If it's double click I would like to have a LineEdit pop up. QAbstractItemView::CurrentChanged and QAbstractItemView::SelectedClicked should result in showing a button.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Check what EditTrigger triggered the QStyledItemDelegate

    No, createEditor() is not a right place to detect such things. You can probably catch that in editorEvent() as different triggers are caused by different events.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    torres (12th April 2011)

  4. #3
    Join Date
    Mar 2011
    Posts
    15
    Thanks
    4
    Qt products
    Qt4

    Default Re: Check what EditTrigger triggered the QStyledItemDelegate

    Quote Originally Posted by wysota View Post
    No, createEditor() is not a right place to detect such things. You can probably catch that in editorEvent() as different triggers are caused by different events.
    I read somewhere in the documentation that there's either the createEditor approach or using editorEvent().
    Then I have to get rid of the createEditor() function? How would I draw the custom LineEdit widget and the button that I return up to now in createEditor?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Check what EditTrigger triggered the QStyledItemDelegate

    Quote Originally Posted by torres View Post
    I read somewhere in the documentation that there's either the createEditor approach or using editorEvent().
    It's not that simple. You can use both if you want.

    Then I have to get rid of the createEditor() function?
    No. Determine the trigger in editorEvent() and then use that knowledge in createEditor().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QGraphicsItem paint not triggered
    By roband915 in forum Qt Programming
    Replies: 9
    Last Post: 31st March 2011, 10:06
  2. Replies: 2
    Last Post: 20th October 2010, 16:16
  3. Replies: 3
    Last Post: 28th September 2010, 10:48
  4. Replies: 1
    Last Post: 11th April 2010, 14:21
  5. Replies: 2
    Last Post: 24th September 2009, 00:49

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.