QString text = index.data().toString(); QRect rect = option.rect; QTextOption opt(option.displayAlignment); if(index.column() == 9) opt.setAlignment(Qt::AlignVCenter | Qt::AlignLeft); else opt.setAlignment(Qt::AlignCenter); opt.setWrapMode(QTextOption::WordWrap); painter->save(); painter->drawRect(rect); painter->drawText(rect, text, opt); painter->restore();
C++ (Qt)rect.setX(rect.x() + indent);
verticalHeader()->resizeSections(QHeaderView::ResizeToContents);
QString text = index.data().toString(); QRect rect = option.rect; QTextOption opt(option.displayAlignment); if(index.column() == 9) { opt.setAlignment(Qt::AlignVCenter | Qt::AlignLeft); } else opt.setAlignment(Qt::AlignCenter); opt.setWrapMode(QTextOption::WordWrap); painter->save(); painter->drawRect(rect); rect.setX(rect.x() + 3); painter->drawText(rect, text, opt); painter->restore();