Results 1 to 4 of 4

Thread: Model: ItemIsUserCheckable

  1. #1
    Join Date
    Jul 2006
    Location
    France
    Posts
    34
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Red face Model: ItemIsUserCheckable

    Hye all

    I'm still trying to create my own ItemModel for my data structure in PyQt.
    This model is quiet "readable only" (and now it works great thanks to you ).
    But I would like my users to be able to check a check box (that represent a boolean value).

    For this column, I use the flag:
    QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEditable

    The data are correctly display, but my user can't 'check' this check box.
    I add a setData method to my model, but it do not seems to be called at all.

    What am I doing wrong ?

  2. #2
    Join Date
    Jul 2006
    Location
    France
    Posts
    34
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Model: ItemIsUserCheckable

    Ok, I should be (a very bit?) stupid!

    The fault was in my "delegate" where I do only something like this:

    Qt Code:
    1. def editorEvent(self, event, proxyModel, option, proxyIndex):
    2. eventType = event.type()
    3. if eventType == QtCore.QEvent.MouseButtonDblClick:
    4. [...] # <- we do not care
    5. return True
    6. return False
    To copy to clipboard, switch view to plain text mode 

    Should I do something "else" ?

  3. #3
    Join Date
    Jul 2006
    Location
    France
    Posts
    34
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Re: Model: ItemIsUserCheckable

    When I replace my delegate by a simple QItemDelegate, the 'check' behavior is as I excepted, but when I had only the method:
    Qt Code:
    1. def editorEvent(self, event, proxyModel, option, proxyIndex):
    2. eventType = event.type()
    3. if eventType == QtCore.QEvent.MouseButtonDblClick:
    4. [...] # <- we do not care
    5. return True
    6. return False
    To copy to clipboard, switch view to plain text mode 

    The check do not work anymore...
    Any idea ?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Model: ItemIsUserCheckable

    Well, filtering out mouse events is not a very good way of implementing "read-only" functionality.
    • If you want the whole view to be non-editable, adjustQAbstractItemView::EditTriggers.
    • If you want only certain items to be non-editable, don't return "ItemIsEditable" for them!
    J-P Nurmi

Similar Threads

  1. Sharing Selections between Model and ProxyModel
    By mentat in forum Qt Programming
    Replies: 14
    Last Post: 27th January 2010, 17:31
  2. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  3. Coin3d + Qt: SIGLNALs and SLOTs
    By vonCZ in forum Newbie
    Replies: 26
    Last Post: 15th May 2009, 07:34
  4. Help with Model View
    By weepdoo in forum Qt Programming
    Replies: 13
    Last Post: 12th October 2007, 10:32
  5. Model Choices review/questions
    By ucntcme in forum Qt Programming
    Replies: 1
    Last Post: 16th September 2007, 21:57

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.