当前位置:网站首页>QT draw text
QT draw text
2022-04-23 12:15:00 【MechMaster】
Qt Draw text
void Widget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QRectF rect(10.0,10.0,380.0,280.0);
painter.setPen(Qt::red);
painter.drawRect(rect);
painter.setPen(Qt::blue);
// Parameters : The rectangle where the text is drawn 、 Align text in rectangle 、 Drawn text \n Can realize line feed
painter.drawText(rect,Qt::AlignHCenter,tr("AlignHCenter"));
painter.drawText(rect,Qt::AlignLeft,tr("AlignLeft"));
painter.drawText(rect,Qt::AlignRight,tr("AlignRight"));
painter.drawText(rect,Qt::AlignHCenter,tr("AlignHCenter"));
painter.drawText(rect,Qt::AlignBottom,tr("AlignBottom"));
painter.drawText(rect,Qt::AlignCenter,tr("AlignCenter"));
painter.drawText(rect,Qt::AlignBottom | Qt::AlignBottom,tr("AlignBottom/AlignBottom"));
// Parameters : The font family attribute 、 size 、 Is it in bold 、 Whether to use italics
QFont font(" Song style ",15,QFont::Bold,true);
// Set underline
font.setOverline(true);
// Set letter case
font.setCapitalization(QFont::SmallCaps);
// Set the spacing between characters
font.setLetterSpacing(QFont::AbsoluteSpacing,10);
// Using fonts
painter.setFont(font);
painter.setPen(Qt::red);
painter.drawText(120,80,tr("Hello world!"));
painter.translate(100,100);
painter.rotate(90);
painter.drawText(0,0,tr("Hello Qt!"));
}
版权声明
本文为[MechMaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231210424030.html
边栏推荐
- How much does software testing help reduce program bugs?
- 第四章 为IM 启用填充对象之启用和禁用列(IM-4.3 第三部分)
- VMware virtual machines export hard disk vmdk files using esxi
- In idea Solution to the problem of garbled code in Chinese display of properties file
- Purpose of IM expression (IM 5.2)
- AI video cloud vs narrowband HD, who is the darling of the video era
- 编程辅助工具推荐:图片工具snipaste
- 第二十六课 类的静态成员函数
- IM 体系结构:CPU架构:SIMD向量处理(IM-2.3)
- 力扣-1137.第N个泰波那契数
猜你喜欢
外包干了五年,废了...
Here comes the detailed picture and text installation tutorial of H5 game
在 VSCode 中调试 Jest 的测试用例,VSCode调试Jest测试用例报错basedir=$(dirname “$(echo “$0“ | sed -e ‘s,\\,/,g‘)“)解决
论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
Force buckle - 1137 Nth teponacci number
Outsourcing for five years, abandoned
In idea Solution to the problem of garbled code in Chinese display of properties file
Fastjson 2 来了,性能继续提升,还能再战十年
worder字体网页字体对照表
Database Navigator 使用默认MySQL连接提示:The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or repres
随机推荐
Windows2008系统如何切换PHP版本
Metalama简介4.使用Fabric操作项目或命名空间
WIN10 启动后花屏
Interpretation 3 of gdpr series: how do European subsidiaries return data to domestic parent companies?
关于使用Go语言创建WebSocket服务浅谈
Castle. Dynamic proxy implements transaction unit control
网络信息安全之零信任
Chapter 4 specifies the attribute of the inmemory column on the no inmemory table for im enabled filling objects: examples (Part IV of im-4.4)
C# F23. Stringsimilarity Library: String repeatability, text similarity, anti plagiarism
Im architecture: CPU architecture: SIMD vector processing (im-2.3)
传统企业如何应对数字化转型?这些书给你答案
数据库如何填充IM表达式(IM 5.4)
程序员如何用130行代码敲定核酸统计
oh-my-lotto
激活函数之sigmoid函数
SPSS之单因素方差分析
获取钉钉考勤机打卡记录
Force buckle - 1137 Nth teponacci number
SQLserver怎么插入或更新当天的星期数,bit而不是文本
5个免费音频素材网站,建议收藏