Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Dynamically creating checkboxes
moyin last edited by
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.
VRonin last edited by
Normally in these cases you don't need checkboxes but a checkable list like QListWidget
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 :)