I have a QTableWidget and 1 column has only checkboxes, so for those items I have these flags:
/* create prototype for checkbox item */
checkItem = new QTableWidgetItem();
Qt::ItemFlags flags = checkItem->flags();
flags &= ~Qt::ItemIsEditable;
flags &= ~Qt::ItemIsDropEnabled;
flags &= ~Qt::ItemIsDragEnabled;
flags |= Qt::ItemIsUserCheckable;
checkItem->setFlags(flags);
/**/
Ok that works... almost. I can't drop anything in those items, that's good. But now there can be dropped in between 2 cells, so there is a new row created. How can I prevent that? In the other columns where the cells are drop-enabled, I can only drop in the cells and not in between and that is good. Why is this behavior changed when the item is not drop-enabled?
A fast hack using an event filter (could need some tweaks):
What you do this is ignore any drop on the checkbox column. So it should be enough to disable row creation.
Info about eventFilters:
Event Filters