Mat*_*ips 6 c++ model-view-controller qt delegates
相当困惑的是这个省略 - 但在Qt的QAbstractItemView类中,可以使用这些方法将QAbstractItemDelegate(即QItemDelegate或QStyledItemDelegate)设置为整个视图,单行或单个列setItemDelegate*.此外,可以查询单个单元格的项目委托QAbstractItemView::itemDelegate(const QModelIndex&),以及行,列的委托.和整个观点.但是,似乎没有办法设置的项目委托给一个单独的单元格.我错过了什么吗?这应该是什么原因?
不,您不能仅为一个单元格或一列设置项目委托,但您可以轻松地为整个窗口小部件设置项目委托,并选择要使用自定义绘画或其他内容的单元格,列或行.
例如
void WidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.column() == 1)
{
// ohh it's my column
// better do something creative
}
else // it's just a common column. Live it in default way
QItemDelegate::paint(painter, option, index);
}
Run Code Online (Sandbox Code Playgroud)
您可以在此处找到更多信息
| 归档时间: |
|
| 查看次数: |
9432 次 |
| 最近记录: |