当前位置:网站首页>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
边栏推荐
- 力扣-1137.第N个泰波那契数
- Why is there a wrapper class? By the way, how to convert basic data types, wrapper classes and string classes?
- 智能多线弹性云增加独立的IP地址,如何实现多线功能?
- 5个免费音频素材网站,建议收藏
- Relu function of activation function
- C# F23. Stringsimilarity Library: String repeatability, text similarity, anti plagiarism
- 软件测试对于减少程序BUG有多大帮助?
- Force buckle - 70 climb stairs
- Idea code formatting plug-in save actions
- What is a gateway
猜你喜欢
Idea code formatting plug-in save actions
VMware虚拟机使用esxi 导出硬盘vmdk文件
九十八、freemarker框架报错 s.e.ErrorMvcAutoConfiguration$StaticView : Cannot render error page for request
在 VSCode 中调试 Jest 的测试用例,VSCode调试Jest测试用例报错basedir=$(dirname “$(echo “$0“ | sed -e ‘s,\\,/,g‘)“)解决
软件测试基础DAY2-用例执行
SPSS之单因素方差分析
Idea code quality specification plug-in sonarlint
A detailed explanation of head pose estimation [collection of good articles]
PSCP 基本使用
Tan Xiang, CEO of Kechuang · Pera software: the essence of zero trust is digital security. To B should also deeply study the user's mind
随机推荐
Share two practical shell scripts
Pagoda panel command line help tutorial (including resetting password)
Qt一个进程运行另一个进程
Windows2008系统如何切换PHP版本
How the database fills in IM expressions (IM 5.4)
How to switch PHP version in Windows 2008 system
Sigmoid function of activation function
WIN10 启动后花屏
力扣-70.爬楼梯
ThinkPHP adds image text watermark to generate promotion poster with QR code
AI 视频云 VS 窄带高清,谁是视频时代的宠儿
The fourth chapter is the enable and disable columns of IM enabled fill objects (Part III of im-4.3)
第四章 为IM 启用填充对象之为IM列存储启用ADO(IM 4.8)
C# F23.StringSimilarity库 字符串重复度、文本相似度、防抄袭
Lesson 26 static member functions of classes
Use kettle to copy records to and get records from results
Next.js 静态数据生成以及服务端渲染的方式
Relu function of activation function
激活函数之阶跃函数
Summary of convolution layer and pooling layer