当前位置:网站首页>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
边栏推荐
- 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
- ThinkPHP adds image text watermark to generate promotion poster with QR code
- SQLserver怎么插入或更新当天的星期数,bit而不是文本
- worder字体网页字体对照表
- How imeu is associated with imcu (IM 5.5)
- Intelligent multi line elastic cloud adds independent IP address. How to realize multi line function?
- IFLYTEK's revenue in 2021 was 18.3 billion yuan: a year-on-year increase of 41% and a net profit of 1.556 billion yuan
- 如果你是一个Golang面试官,你会问哪些问题?
- Next. JS static data generation and server-side rendering
- 九十八、freemarker框架报错 s.e.ErrorMvcAutoConfiguration$StaticView : Cannot render error page for request
猜你喜欢
随机推荐
Why is there a wrapper class? By the way, how to convert basic data types, wrapper classes and string classes?
IDEA设置版权信息
Master slave replication configuration of MySQL
论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
IM 体系结构:CPU架构:SIMD向量处理(IM-2.3)
用户接口和IM表达式(IM 5.6)
Idea setting copyright information
Fabric 1.0源代码分析(33) Peer #peer channel命令及子命令实现
2022 love analysis · panoramic report of industrial Internet manufacturers
C# F23. Stringsimilarity Library: String repeatability, text similarity, anti plagiarism
智能多线弹性云增加独立的IP地址,如何实现多线功能?
Outsourcing for five years, abandoned
【Redis 系列】redis 学习十三,Redis 常问简单面试题
魔域来了H5游戏详细图文架设教程
[redis series] redis learning 13. Redis often asks simple interview questions
How imeu is associated with imcu (IM 5.5)
PSCP basic usage
AI 视频云 VS 窄带高清,谁是视频时代的宠儿
IMEU如何与IMCU相关联(IM 5.5)
PSCP 基本使用








