Results 1 to 7 of 7

Thread: Question re QCheckBox and delegate

  1. #1
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Question re QCheckBox and delegate

    If I wanted to intercept the click event on a QTreeView holding QStandardItems, where would the best place to catch it ?

    I don't want the QItemDelegate::createEditor() function to create a check box, rather I want the delegate to ignore it and to set or clear the displayed one that QStandardItemModel::data() shows with either a single or double-click.

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question re QCheckBox and delegate

    Since the delegate does not have that ability, I suppose that you have to subclass the view.

  3. #3
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Question re QCheckBox and delegate

    setEditTriggers(QAbstractItemView::NoEditTriggers) affects the whole view.
    Can't a single column be singled out ?

  4. #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: Question re QCheckBox and delegate

    How about connecting to the QAbstractItemView::clicked() signal?
    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.


  5. #5
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Question re QCheckBox and delegate

    Yeah, sure. I've already considered it, that's an easy solution, but a bit of a hack isn't it ? If it's the only option then there remains one last question. How to block the delegate from receiving any further signal. I guess setEditorData is the logical place, but you have to return an object... or do you ?

    edit: I meant createEditor(), not setEditorData()
    Last edited by vieraci; 22nd June 2009 at 09:17. Reason: spelling error

  6. #6
    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: Question re QCheckBox and delegate

    What's so hackish in using a signal for things it is meant to be used for? Maybe I don't see what your problem is... could you elaborate on it? The checkbox you see in the view is not created by the delegate's createEditor() method. There is no real checkbox there - the delegate draws the checkbox and handles clicking on it through editorEvent(). If you want to check/uncheck the box in some other way, just do it.
    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.


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

    vieraci (22nd June 2009)

  8. #7
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Question re QCheckBox and delegate

    Quote Originally Posted by wysota View Post
    the delegate draws the checkbox and handles clicking on it through editorEvent().
    Why Thank you wysota, That's the method I was looking for.

Similar Threads

  1. QCheckBox on QDataWidgetMapper
    By Banjo in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2008, 03:09

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.