I am going to change the display text for one of my QTableView
column. I inherit from QStyledItemDelegate
class and change the definition of displayText
according to the following:
QString CellIdDelegate::displayText(const QVariant &value, const QLocale &locale) const
{
QString currentColumn = value.toString();
QString anotherColumn = ....;
return currentColumn + anotherColumn;
}
and then use setItemDelegateForColumn
.
How I can access to the value of another column in my QTableView
.
You can't since displayText() is for exactly one cell. It's only meant to add eg a prefix or suffix. If you want to display other text, modify the data returned by Qt::DisplayRole accordingly. This is nothing for a delegate.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.