当前位置:网站首页>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
边栏推荐
- Fabric 1.0源代码分析(33) Peer #peer channel命令及子命令实现
- IDEA 代码格式化插件Save Actions
- 第五章 使用In-Memory表达式优化查询(IM 5.1)
- Symmetric encryption, certificate encryption
- Next.js 静态数据生成以及服务端渲染的方式
- PSCP 基本使用
- Tclerror: no display name and no $display environment variable
- Outsourcing for five years, abandoned
- IDEA 代码质量规范插件SonarLint
- User interface and im expression (IM 5.6)
猜你喜欢

Next.js 静态数据生成以及服务端渲染的方式

在 VSCode 中调试 Jest 的测试用例,VSCode调试Jest测试用例报错basedir=$(dirname “$(echo “$0“ | sed -e ‘s,\\,/,g‘)“)解决

Idea database navigator plug-in

worder字体网页字体对照表

亿级流量架构,服务器如何扩容?写得太好了!

Idea setting copyright information
![[redis series] redis learning 13. Redis often asks simple interview questions](/img/4c/2440af6daa26a0ca6cb64f32bf138e.png)
[redis series] redis learning 13. Redis often asks simple interview questions
![A detailed explanation of head pose estimation [collection of good articles]](/img/59/6ac8692b0dbd0218bb512c5eac3124.png)
A detailed explanation of head pose estimation [collection of good articles]

Practical data Lake iceberg lesson 30 MySQL - > iceberg, time zone problems of different clients

激活函数之relu函数
随机推荐
第四章 为IM 启用填充对象之启用和禁用列(IM-4.3 第三部分)
论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
第五章 使用In-Memory表达式优化查询(IM 5.1)
Debug Jest test cases in VSCode, debug Jest test cases in VSCode, middle note basedir=$(dirname "$" (echo "$0" sed -e -e, s, \ \, / "-e").
科创人·派拉软件CEO谭翔:零信任本质是数字安全,To B也要深研用户心智
IDEA 代码质量规范插件SonarLint
Win10 splash screen after startup
Redis learning 5 - high concurrency distributed lock practice
面了一圈,整理了这套面试题。。
对称加密、证书加密
IDEA 数据库插件Database Navigator 插件
软件测试对于减少程序BUG有多大帮助?
Idea code formatting plug-in save actions
编程辅助工具推荐:图片工具snipaste
Next. JS static data generation and server-side rendering
On lambda powertools typescript
获取钉钉考勤机打卡记录
Fastjson 2 来了,性能继续提升,还能再战十年
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)
How Im expressions work (5.3)