Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Why does the QCheckBox not show the text



  • Hi,

    I'm having a QListWidget to which I'm adding QCheckBoxes`` which works fine but I can't see thetext``` which I'm adding with the constructor. I'm wondering what I might be missing, the related code looks like:

    list = new QListWidget(this);
    	item = new QListWidgetItem();
    	item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
    	item->setCheckState(Qt::Unchecked);
    	list->setItemWidget(item,new QCheckBox("checkBox"));
    	list->addItem(item);
    


  • @cerr

    You dont see the text, because what you see is the (checkable) QListItem, not your QCheckBox. If you set Qt::ItemIsUserCheckable the ListItem itself gets a little checkBox. As far as I know, you dont need the additional checkBox at all...


Log in to reply