PDA

View Full Version : how to make icon sell unhighlightable in tableWidget?



sehnkim
21st April 2016, 18:18
Hello

I added a tableWidget, and want to have 1st column with name and 2nd column with status icon.
But I don't want the user to highlight the cell. (no interaction at all.)
I tried to use Qt::ItemIsEnabled, but it made my icon gray.
Is there any better approach I can try?
Thanks a lot.



int rowCount = ui->tableWidget->rowCount();
ui->tableWidget->insertRow(rowCount);

QTableWidgetItem* item = new QTableWidgetItem(user_name);
ui->tableWidget->setItem(rowCount, 0, item);

// Connection status.
item = new QTableWidgetItem;
QIcon icon_connection(":/images/connected.png");
item->setIcon(icon_connection);
item->setFlags(item->flags() ^ Qt::ItemIsEnabled);
ui->tableWidget->setItem(rowCount, 1, item);
item->setToolTip(CONNECTION_STATUS);

anda_skoa
21st April 2016, 19:14
Qt::ItemIsSelectable?

Cheers,
_

sehnkim
22nd April 2016, 17:38
Thanks a lot, but actually I've tried with that.
For some reason, I've got a dotted line around the cell I selected.
Do you know how I can remove the line?
11904