Hello!
I 'm fighting a little bit with a QTableWidget. There are three columns in it and I like to have only the QTableWidgetItems in one column editable and to accept drops.
First I have created the tableWidget using the designer and there I have dragDropMode=No DragDrop for the QTableWidget itself. Then I've created my items like this:
for ( int i = 0; i < query.size(); ++i )
{
tableWidget->insertRow( i );
tableWidget->setItem( i, 0, newItemField );
tableWidget->setItem( i, 1, newItemTyp );
tableWidget->setItem( i, 2, newItemValue );
newItemValue->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled );
qDebug() << newItemValue->flags();
query.next();
}
for ( int i = 0; i < query.size(); ++i )
{
tableWidget->insertRow( i );
QTableWidgetItem *newItemField = new QTableWidgetItem( query.value( 0 ).toString() );
tableWidget->setItem( i, 0, newItemField );
QTableWidgetItem *newItemTyp = new QTableWidgetItem( query.value( 1 ).toString() );
tableWidget->setItem( i, 1, newItemTyp );
QTableWidgetItem *newItemValue = new QTableWidgetItem( "" );
tableWidget->setItem( i, 2, newItemValue );
newItemValue->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled );
qDebug() << newItemValue->flags();
query.next();
}
To copy to clipboard, switch view to plain text mode
qDebug() << newItemValue->flags() shows me 42. If I am right, 42 means, the item is enabled, is editable and will accept drops.
The problem is, it's enabled (at least it's not grey) but it's not editable and it don't accept drops.
Where I have done the mistake in thinking?
Regards
Guenther
Bookmarks