Results 1 to 5 of 5

Thread: How to dinamically change the type of a QCheckListItem

  1. #1
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question How to dinamically change the type of a QCheckListItem

    I have a list view made up by check list items.

    The type of parent list view items is CheckBoxController while the type of leaves items is CheckBox (this distinction is needed in order to properly manage the tristate of the QCheckListItem).

    The user can delete all children of an item, in such case I have to change the type of such item from CheckBoxController to CheckBox otherwise the tristate is wrongly managed.

    Is there a way to easily change the type of a QCheckListItem at run time?

    Thanks a lot for your help.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How to dinamically change the type of a QCheckListItem

    You'll have to create a new object of a proper class.

  3. #3
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to dinamically change the type of a QCheckListItem

    Can you be more specific?

    I already have a class derived from the QCheckListItem but the QCheckListItem is not providing any way to change the type of the QCheckListItem. The only way to specify the type is to pass it in the constructor, but I need to change the type after the object has been created.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How to dinamically change the type of a QCheckListItem

    I mean you have to create a "CheckBox" instance and replace the "CheckBoxController" instance with it. You can't change the class of an already existing object. Of course you can make the "Controller" class a subclass of the "CheckBox" class and extend it to provide additional functionality, which could just be "downgraded" when the item has no children.

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

    kalos80 (12th March 2007)

  6. #5
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to dinamically change the type of a QCheckListItem

    Wysota thank you very much for your hints, I'm gonna implement them.

Similar Threads

  1. Installation on Fedora Core 4
    By jcr in forum Installation and Deployment
    Replies: 3
    Last Post: 29th January 2009, 01:34
  2. When itemChanged is emitted, can the change type be detected?
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 7th April 2006, 17:29

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.