Results 1 to 4 of 4

Thread: When using editorEvent in QItemDelegate, the QStyle::State_Selected doesnt arrive

  1. #1
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Question When using editorEvent in QItemDelegate, the QStyle::State_Selected doesnt arrive

    When using editorEvent in QItemDelegate, the QStyle::State_Selected doesn't arrive in the editorEvent but it does in paint. I'm using QStyleOptionViewItem.state.

    Qt Code:
    1. bool InCallItemDelegate::editorEvent(QEvent * event, QAbstractItemModel * model
    2. , const QStyleOptionViewItem & option, const QModelIndex & index )
    3. {
    4. if((option.state & QStyle::State_Selected) == QStyle::State_Selected)
    5. {
    6. //This does not arrive.
    7. }
    8. }
    9.  
    10. void InCallItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
    11. {
    12. if((option.state & QStyle::State_Selected) == QStyle::State_Selected)
    13. {
    14. //This works
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    Should I capture the selection in some other way? Could be a QT bug? Im using 4.7.0


    Thanks
    Ramiro

  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: When using editorEvent in QItemDelegate, the QStyle::State_Selected doesnt arrive

    editorEvent() handles many types of events. Some of them have information about selection and some don't.
    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:

    boblatino (21st September 2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: When using editorEvent in QItemDelegate, the QStyle::State_Selected doesnt arrive

    I'm catching all the events in the example provided and I'm selecting a item in the UI. When I do that, the paint is called with the selection but the editorEvent doesn't. What could be happening? Should I register for some type of events like an eventFilter? I need the selection because I'm catching MouseButtonPress, MouseButtonRelease and I need to know if the clicked item is selected (because if its selected I do an action, else I change the selection).


    Thanks
    Ramiro

  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: When using editorEvent in QItemDelegate, the QStyle::State_Selected doesnt arrive

    Quote Originally Posted by boblatino View Post
    When I do that, the paint is called with the selection but the editorEvent doesn't.
    Let me repeat myself, but only once. editorEvent() handles many types of events, not a particular one. You can't just look at one event which doesn't contain information about selection and say that editorEvent() doesn't have information about selection. Sometimes it does, sometimes it doesn't, it all depends on the type of event it is currently handling. It's a direct equivalent of QObject::event().
    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.


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

    boblatino (21st September 2010)

Similar Threads

  1. Replies: 2
    Last Post: 14th July 2011, 13:28
  2. QItemDelegate and QStyle::State_Selected
    By cydside in forum Qt Programming
    Replies: 3
    Last Post: 26th July 2010, 07:08
  3. signal doesnt emit
    By mark2804 in forum Newbie
    Replies: 2
    Last Post: 25th December 2008, 23:36
  4. QItemDelegate::editorEvent
    By jml in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2008, 01:26
  5. How come this doesnt work?
    By ShaChris23 in forum Newbie
    Replies: 8
    Last Post: 16th June 2007, 05:43

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.