Results 1 to 4 of 4

Thread: How QCheckBox into QListWidgetItem?

  1. #1
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    64
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How QCheckBox into QListWidgetItem?

    Can somebody show some examplecode about how to insert a QCheckBox into
    a QListWidgetItem?

    Thanks.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How QCheckBox into QListWidgetItem?

    It is easy enough. Use QListWidget::setItemWidget(QListWidgetItem*, QWidget*);
    Something like:
    Qt Code:
    1. myList->setItemWidget(someListItem, new QCheckBox("checkBox"));
    To copy to clipboard, switch view to plain text mode 

    Note that you need a reference to the item for which you want to set the widget.

    Regards

  3. #3
    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: How QCheckBox into QListWidgetItem?

    Qt Code:
    1. item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
    2. item->setCheckState(Qt::Unchecked);
    To copy to clipboard, switch view to plain text mode 
    Please search the forums next time. This subject has been discussed several times.
    J-P Nurmi

  4. #4
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    64
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How QCheckBox into QListWidgetItem?

    Tnx, I didn't expect that it should be that simple

Similar Threads

  1. Check Box problem
    By Seema Rao in forum Qt Programming
    Replies: 6
    Last Post: 30th November 2007, 19:32
  2. about QListWidgetItem
    By Pang in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2007, 09:14
  3. QListWidgetItem Text Rect
    By js67257 in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2006, 12:02
  4. Problems subclassing QListWidgetItem
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 8th May 2006, 09:27
  5. QListWidget add QListWidgetItem
    By fellobo in forum Qt Programming
    Replies: 3
    Last Post: 20th February 2006, 19:37

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.