[SOLVED] Checkboxes in QListWidget appear as locked

  • Hi everybody,

    I'm quite new to Qt, with a few months of experience.

    I'm currently working with a project that contains a QListWidget, mainly because it's an easy solution to create lists of slightly more complex widgets. I'm trying to give each new list item a checkbox. In my current code, this is done by:

    @ListFrame *frame1 = new ListFrame(this);
    QListWidgetItem *item = new QListWidgetItem();
    item->setFlags(item->flags() | Qt::ItemIsUserCheckable);


    My ListFrame class is simply a frame with a number of labels in it.
    If I omit the "Qt::ItemIsUserCheckable" flag, the checkbox in my list is greyed out. With the flag, however, the checkbox is not greyed out, but it's still behaving as though it were disabled! I've tried clicking the frame that is my item, the labels that it contains, or the checkbox itself, and it never changes state. Note that this problem persists even if I use a standard class such as QLabel instead of my ListFrame.

    Have I misunderstood something? According to all other info I've found, it should be enough to add the flag ItemIsUserCheckable and set a checked or unchecked state.

    Thanks for any help!

  • Lifetime Qt Champion


    Great you found out and shared the solution !

    Can you also update the thread title prepending [solved] so other forum users may know a solution has been found :)

  • Oh, right. I was looking for a "Solved" button somewhere. Done! :D

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.