Results 1 to 4 of 4

Thread: Multiple ListViews and checkbox problem

  1. #1
    Join Date
    Nov 2008
    Posts
    33
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Multiple ListViews and checkbox problem

    I have a StandardItemModel - call it myModel.
    I have several ListViews on different pages of a Wizard which all use myModel.
    All items in myModel are checkable.
    Everything works fine; I get my checkboxes in the ListView as desired.

    The Problem: I want a new ListView, again based on myModel, but I don't want to see the checkboxes this time.

    The Question:Is there a way of telling the new ListView "don't display a checkbox even if the item is checkable"?

    Note 1. I have tried overriding the StandardItem::flags() function to return Qt::ItemIsUserCheckable as necessary but it never gets called before ListView is painted.
    Note 2. I could clone myModel and set every item to non checkable; this would give me great problems in maintaining the state of both models though.)

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: Multiple ListViews and checkbox problem

    Hi,

    maybe you can just return QVariant() for CheckStateRole/DecorationRole in the data() function of your model if you dont want to show the checkboxes. ... just a guess. Dont know if it works.

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

    onamatic (8th January 2009)

  4. #3
    Join Date
    Nov 2008
    Posts
    33
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Multiple ListViews and checkbox problem

    Quote Originally Posted by janus
    maybe you can just return QVariant() for CheckStateRole/DecorationRole.
    Hi janus,

    Many thanks for the suggestion; unfortunately those flags only affect whether a checkbox is checked and what to render as an icon respectively. Neither affect whether a checkbox is drawn or not.

  5. #4
    Join Date
    Nov 2008
    Posts
    33
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Multiple ListViews and checkbox problem

    Quote Originally Posted by onamatic View Post
    Hi janus,

    Many thanks for the suggestion; unfortunately those flags only affect whether a checkbox is checked and what to render as an icon respectively. Neither affect whether a checkbox is drawn or not.
    My apologies janus for my hasty reply. Your suggestion to return QVariant() for CheckStateRole was spot on the money. (Other bits of code conspired to make it seem as if it weren't working when I tried it yesterday.) Thank you.

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.