why my qtable widget slightly move on click of last column cell of it ?
-
i have 2 row and 3 column Qtable widget.
when i click on qtable widget last column it moves slightly.
i want to disable click on it .
means i want to use this qtable widget only for display data.
so what i need to do to make non clickable qtable widget ?
-
@Qt-embedded-developer
Do it in a loop over all items after you have added them. Or, write asetItem()
helper or subclass yourQTableWidget
/QTableWidgetItem
s to always set the flags whenever you create aQTableWidgetItem
to add into yourQTableWidget
. There are so many ways.Or, try my
tableWidget->setEnabled(false)
to set the wholeQTableWidget
disabled in one statement, if the result you get is acceptable to you. -
@Qt-embedded-developer
Depending on what you mean, what aboutQTableWidgetItem::setFlags(Qt::NoItemFlags)
, or maybe justflags() & ~Qt::ItemIsSelectable
? -
@Qt-embedded-developer
Did you read what I typed? Or look it up? You have not done what I typed.If you want to do something on the whole table, try
tableWidget->setEnabled(false)
. But it may make the table look a bit different, you'd have to try it. -
@JonB Yes i have see this but when i use
QTableWidgetItem* ptableitem1 = new QTableWidgetItem();
ptableitem1->setFlags(Qt::NoItemFlags);
ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,1,ptableitem1);but this i need to use again and again for last column all cell . so is there any logic is there which will work generic way for complete QTreewidget ?
-
@Qt-embedded-developer
Do it in a loop over all items after you have added them. Or, write asetItem()
helper or subclass yourQTableWidget
/QTableWidgetItem
s to always set the flags whenever you create aQTableWidgetItem
to add into yourQTableWidget
. There are so many ways.Or, try my
tableWidget->setEnabled(false)
to set the wholeQTableWidget
disabled in one statement, if the result you get is acceptable to you.