Nominate our 2022 Qt Champions!

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);
    	list->setItemWidget(item,new QCheckBox("checkBox"));

  • @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