qt table中字体倾斜

在itemdelegate,的paint事件中添加

                QStyleOptionViewItem newOption(option);
                QTransform transform(QTransform::fromTranslate(-option.rect.center().x(),
                                                               -option.rect.center().y()));
                transform.rotate(90);
                painter->setTransform(transform);
                transform=transform.inverted();
                newOption.rect=transform.mapRect(newOption.rect);
                //HtItemModelDeletage::paint(painter, newOption, index);
                 painter->drawText(newOption.rect,Qt::AlignCenter,celldata);
                // restore state of painter
                painter->setTransform(transform);

posted @ 2017-12-13 15:50  beautifulday  阅读(869)  评论(0编辑  收藏  举报