其他分享
首页 > 其他分享> > Qt绘制垂直文本drawText

Qt绘制垂直文本drawText

作者:互联网

        painter.drawText(800-ui->lineEdit_right->text().toInt(),
                         ui->lineEdit_top->text().toInt()+70, 12, 50,
                         Qt::AlignTop | Qt::TextSingleLine | Qt::TextWordWrap,
                         "白存根");

        painter.drawText(800-ui->lineEdit_right->text().toInt(),
                         ui->lineEdit_top->text().toInt()+125, 12, 50,
                         Qt::AlignTop | Qt::TextSingleLine | Qt::TextWordWrap,
                         "蓝仓库");

        painter.drawText(800-ui->lineEdit_right->text().toInt(),
                         ui->lineEdit_top->text().toInt()+180, 12, 50,
                         Qt::AlignTop | Qt::TextSingleLine | Qt::TextWordWrap,
                         "红财务");
        painter.drawText(800-ui->lineEdit_right->text().toInt(),
                         ui->lineEdit_top->text().toInt()+235, 12, 50,
                         Qt::AlignTop | Qt::TextSingleLine | Qt::TextWordWrap,
                         "黄客户");

还有一种是整行文字旋转90度。

    painter.rotate(90);
    painter.drawText(y-30, -x, "电流值");
 
    painter.rotate(180);
    painter.drawText(-y-6, 20, "电压值");

标签:drawText,Qt,text,toInt,ui,lineEdit,文本,painter
来源: https://www.cnblogs.com/mc-r/p/15863386.html