PDA

View Full Version : no matching function for call to 'QTableWidgetItem::setFlags(bool)'



rajil.s
12th February 2017, 20:31
Hello,

I have the following piece of code which works fine in Qt 4.8.6 and 5.6.2, but fails in Qt-5.8. I was trying to make the Item not selectable, but boolean fails in Qt-5.8



QTableWidgetItem *newItem1 = new QTableWidgetItem("");
newItem1->setFlags(not Qt::ItemIsSelectable);


Error is

no matching function for call to 'QTableWidgetItem::setFlags(bool)'


Thanks

jefftee
12th February 2017, 20:56
That's because QTableWidgetItem::setFlags() doesn't take a boolean as an argument, it takes a Qt::ItemFlags enum. To set the flags, you need to OR together the flags you want to set. If you want to turn off a specific flag, leaving the others unchanged, you can do the following:


QTableWidgetItem* item = new QTableWidgetItem();
item->setFlags(item->flags() & ~Qt::ItemIsSelectable);