当前位置:网站首页>QT QLabel控件(使用详解)
QT QLabel控件(使用详解)
2022-08-11 05:15:00 【双子座断点】
本文详细的介绍了TextLabel控件的各种操作,例如:显示边框、设置文字、设置字体、设置信息提示框、状态提示、居中对齐、加载图片、自适应图片大小、设置位置大小、样式表等操作。
本文作者原创,转载请附上文章出处与本文链接。
QLabel控件(使用详解)目录
1 显示边框
ui->label->setStyleSheet("#label{border:2px solid rgb(45,226,42);border-top-left-radius: 5px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 5px;}");
2 设置文字
ui->label->setText("输入文字");
3 设置字体
//QFont font ( "Microsoft YaHei", 10, 75); //第一个属性是字体(微软雅黑),第二个是大小,第三个是加粗(权重是75)
QFont labelFont("Times", 18, QFont::Bold);
ui->label->setFont(labelFont); //设置字体
4 设置信息提示框
ui->label->setToolTip("请输入文字");
5 状态提示
ui->label->setStatusTip("状态提示");
6 居中对齐
ui->label->setAlignment(Qt::AlignCenter); //居中对齐
7 加载图片
ui->label->setPixmap(QPixmap("D:\\a.jpg"));
8 自适应图片大小
ui->label->setScaledContents(true);
9 设置位置大小
ui->label->setGeometry(300, 300, 200, 200);//设置位置大小 x、y、w、h
10 样式表
边栏推荐
猜你喜欢
随机推荐
Some common mysql entry exercises
软件测试风险识别
【转载】CMake 语法 - 详解 CMakeLists.txt
【动态代理】CGLIB 动态代理的使用及原理
oracle tablespace and user creation
【Redis】Redis 的安装及图形化界面 Redis DeskTop Manager 的安装与使用
让你代码越来越高大上的技巧——代码规范,你得知道
手推卷积神经网络参数(卷积核)求导
0708作业---商品信息
Redis - the solution to the failure of connecting to the redis server in linux using jedis
代码在线审查(添加网页批注)的实现
Apache Commons OGNL语法说明_翻译
吃瓜教程task01 第1章 绪论
IDEA使用记录
selenuim使用cookie登录京东
(三)性能实时监控平台搭建(Grafana+Prometheus+Node_explorer+Jmeter)
2022 building welder (building a special type of work) examination questions and simulation test
【win10+cuda7.5+cudnn6.0安装caffe③】编译及测试caffe
IDEA模板总结
玩转mysql之查看mysql版本号