C++ (Qt) if(cellIndex.data(Qt::UserRole).isValid()) { QRect new_r(0, 0, r.width(), r.height()); uniopt.rect = new_r; painter->translate( r.topLeft() ); hv->style()->drawControl(QStyle::CE_HeaderSection, &uniopt, painter, hv); new_r.setWidth(r.height()); new_r.setHeight(r.width()); QMatrix m; m.translate(0, r.height()); m.rotate(-90); painter->setWorldMatrix(m, true); uniopt.rect = new_r; hv->style()->drawControl(QStyle::CE_HeaderLabel, &uniopt, painter, hv); }