当前位置:网站首页>Qt绘制文字
Qt绘制文字
2022-04-23 12:10:00 【MechMaster】
Qt绘制文字
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);
//参数:绘制文字所在的矩形、文字在矩形中的对齐方式、绘制的文字\n能实现换行
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"));
//参数:字体的family属性、大小、是否是用粗体、是否使用斜体
QFont font("宋体",15,QFont::Bold,true);
//设置下划线
font.setOverline(true);
//设置字母大小写
font.setCapitalization(QFont::SmallCaps);
//设置字符间的间距
font.setLetterSpacing(QFont::AbsoluteSpacing,10);
//使用字体
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://liuhui.blog.csdn.net/article/details/124264225
边栏推荐
- The database navigator uses the default MySQL connection prompt: the server time zone value 'Ö Ð¹ ú±ê ×¼ ʱ ¼ ä’ is unrecognized or repres
- Force buckle - 70 climb stairs
- c# 设置logo图标和快捷方式的图标
- 获取钉钉考勤机打卡记录
- 1. Construction of electron development environment
- Intelligent multi line elastic cloud adds independent IP address. How to realize multi line function?
- Resolution due to AMD not found_ ags_ x64. DLL, unable to continue code execution. Reinstallation of the program may solve this problem, Forza horizon 5
- worder字体网页字体对照表
- VMware虚拟机使用esxi 导出硬盘vmdk文件
- How the database fills in IM expressions (IM 5.4)
猜你喜欢
Resolution due to AMD not found_ ags_ x64. DLL, unable to continue code execution. Reinstallation of the program may solve this problem, Forza horizon 5
【Redis 系列】redis 学习十三,Redis 常问简单面试题
外包干了五年,废了...
c# 设置logo图标和快捷方式的图标
Use kettle to copy records to and get records from results
传统企业如何应对数字化转型?这些书给你答案
为什么要有包装类,顺便说一说基本数据类型、包装类、String类该如何转换?
Fastjson 2 is coming, the performance continues to improve, and it can fight for another ten years
Intelligent multi line elastic cloud adds independent IP address. How to realize multi line function?
How do programmers finalize nucleic acid statistics with 130 lines of code
随机推荐
面了一圈,整理了这套面试题。。
Tensorflow common functions
激活函数之sigmoid函数
[web daily practice] eight color puzzle (float)
2022 love analysis · panoramic report of industrial Internet manufacturers
How imeu is associated with imcu (IM 5.5)
How to expand the capacity of the server in the 100 million level traffic architecture? Well written!
激活函数之relu函数
SQL 练习(一)
WIN10 启动后花屏
IDEA 代码格式化插件Save Actions
九十八、freemarker框架报错 s.e.ErrorMvcAutoConfiguration$StaticView : Cannot render error page for request
Database design of forum system
第五章 使用In-Memory表达式优化查询(IM 5.1)
Castle. Dynamic proxy implements transaction unit control
什么是网关
第二十四课 经典问题解析
ThinkPHP adds image text watermark to generate promotion poster with QR code
Database design of simple voting system
The database navigator uses the default MySQL connection prompt: the server time zone value 'Ö Ð¹ ú±ê ×¼ ʱ ¼ ä’ is unrecognized or repres