Dynamically creating checkboxes



  • Actually, i need to create checkboxes dynamically as per user requirements, so which one is the better approach, should i go for scroll area then create checboxes inside that or is there any better approach pls let me know.



  • Normally in these cases you don't need checkboxes but a checkable list like QListWidget


  • Qt Champions 2017

    Hi
    as @VRonin saids a ListWidget with ItemIsUserCheckable is
    often a far better solution than scrollarea.

    QListWidgetItem* item = new QListWidgetItem("item", listWidget);
    item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
    item->setCheckState(Qt::Unchecked); // AND initialize check state ( not sure its 100% needed but i like to be sure :)


Log in to reply
 

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