6

QT添加工具栏_五个板栗的技术博客_51CTO博客

 1 year ago
source link: https://blog.51cto.com/u_15515702/5907067
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

QT添加工具栏

精选 原创

五个板栗 2022-12-02 14:57:19 博主文章分类:Qt ©著作权

文章标签 工具栏 UI 工程文件 文章分类 C/C++ 编程语言 yyds干货盘点 阅读数159

  1. 在工程文件中,找到进入UI界面,左击UI界面,出现如下图,选择Add tool Bar to other Area,选择你想放置的位置,如果默认在顶部,直接选择添加工具栏。
QT添加工具栏_工具栏

如图我添加到了左侧

QT添加工具栏_工具栏_02

2.点击Action Editor ,然后点击新建,出现下图对话框

QT添加工具栏_UI_03
QT添加工具栏_工具栏_04
QT添加工具栏_工程文件_05
QT添加工具栏_工具栏_06

填写文本,设置图标(设置图标需要事前进行第3条)等

3.点击项目,添加新文件,选择QT resource file,

QT添加工具栏_工具栏_07

点击下一步,填写文件名(名字可随意)

QT添加工具栏_UI_08
QT添加工具栏_工程文件_09

4.完成后,出现如下界面,拖动图标到工具栏处,拖动的时候当工具栏出现一条红线,就能放置到工具栏上了

QT添加工具栏_UI_10

QT添加工具栏_工具栏_11

5.运行的效果如下图

QT添加工具栏_工具栏_12

将图标和文本信息一起显示

ui->toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
//将文本信息显示在图标的下方
  • 收藏
  • 评论
  • 分享
  • 举报

上一篇:QT设置窗口图标


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK