×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Question QListWidget with CheckBox

    Dear All,

    i like to display the QListWidgetItem with CheckBoxes
    but its not working, without third line item is selecting , if in include the third line
    item is not all selecting and checkbox also not visible.

    My snippet code:
    QListWidgetItem *widgetitem1 = new QListWidgetItem(ui.listWidget);
    widgetitem1->setText(str);
    widgetitem1->setFlags(widgetitem1->flags()& Qt::ItemIsUserCheckable);


    Any one know how to recify this?any solution?

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QListWidget with CheckBox

    Quote Originally Posted by damodharan View Post
    widgetitem1->setFlags(widgetitem1->flags() & Qt::ItemIsUserCheckable);
    You should use bitwise or instead of bitwise and. You could verify that something is wrong with your code by using
    Code:
    qDebug() << widgetitem1->flags();

  3. #3
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: QListWidget with CheckBox

    Thx for ur answer Danill,but its not working

  4. #4
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QListWidget with CheckBox

    Documentation clearly indicates that you should explicitly call setCheckState on every item
    http://doc.trolltech.com/4.6/qt.html#ItemFlag-enum

Similar Threads

  1. QListWidget : avoid click before selecting
    By henk_marsman in forum Qt
    Replies: 16
    Last Post: 2011-03-29, 16:03
  2. Replies: 3
    Last Post: 2010-02-13, 14:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •