当前位置:网站首页>Qt 容器控件Tool Box 使用详解
Qt 容器控件Tool Box 使用详解
2022-07-30 15:38:00 【陈子青 - See】
目录
功能
QToolBox 工具箱控件,可以存储多个子窗口,该控件可以实现类似 QQ 的抽屉效果,每一个抽屉都可以设置图标和标题,并且对应一个子窗口,通过抽屉按钮就可以实现各个子窗口显示的切换
属性设置

相关API
// 构造函数
QToolBox::QToolBox(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());// 公共成员
/*
addItem(), insertItem()函数相关参数:
- widget: 添加到工具箱中的选项卡对应的子窗口对象
- icon: 工具箱新的选项卡上显示的图标
- text: 工具箱新的选项卡上显示的标题
- index: 指定在工具箱中插入的新的选项卡的位置
*/
// 给工具箱尾部添加一个选项卡, 每个选项卡在工具箱中就是一个子窗口, 即参数widget
int QToolBox::addItem(QWidget *widget, const QString &text);
int QToolBox::addItem(QWidget *widget, const QIcon &icon, const QString &text);
// 在工具箱的指定位置添加一个选项卡, 即添加一个子窗口
int QToolBox::insertItem(int index, QWidget *widget, const QString &text);
int QToolBox::insertItem(int index, QWidget *widget, const QIcon &icon,
const QString &text);
// 移除工具箱中索引index位置对应的选项卡, 注意: 只是移除对应的窗口对象并没有被销毁
void QToolBox::removeItem(int index);// 设置索引index位置的选项卡是否可用, 参数 enabled=true为可用, enabled=false为禁用
void QToolBox::setItemEnabled(int index, bool enabled);
// 设置工具箱中index位置选项卡的图标
void QToolBox::setItemIcon(int index, const QIcon &icon);
// 设置工具箱中index位置选项卡的标题
void QToolBox::setItemText(int index, const QString &text);
// 设置工具箱中index位置选项卡的提示信息(需要鼠标在选项卡上悬停一定时长才能显示)
void QToolBox::setItemToolTip(int index, const QString &toolTip);// 如果位置索引的项已启用,则返回true;否则返回false。
bool QToolBox::isItemEnabled(int index) const;
// 返回位置索引处项目的图标,如果索引超出范围,则返回空图标。
QIcon QToolBox::itemIcon(int index) const;
// 返回位于位置索引处的项的文本,如果索引超出范围,则返回空字符串。
QString QToolBox::itemText(int index) const;
// 返回位于位置索引处的项的工具提示,如果索引超出范围,则返回空字符串。
QString QToolBox::itemToolTip(int index) const;// 得到当前工具箱中显示的选项卡对应的索引
int QToolBox::currentIndex() const;
// 返回指向当前选项卡对应的子窗口的指针,如果没有这样的项,则返回0。
QWidget *QToolBox::currentWidget() const;
// 返回工具箱中子窗口的索引,如果widget对象不存在,则返回-1
int QToolBox::indexOf(QWidget *widget) const;
// 返回工具箱中包含的项的数量。
int QToolBox::count() const;
信号
/信号
// 工具箱中当前显示的选项卡发生变化, 该信号被发射, index为当前显示的新的选项卡的对应的索引
[signal] void QToolBox::currentChanged(int index);
槽函数
// 通过工具箱中选项卡对应的索引设置当前要显示哪一个选项卡中的子窗口
[slot] void QToolBox::setCurrentIndex(int index);
// 通过工具箱中选项卡对应的子窗口对象设置当前要显示哪一个选项卡中的子窗口
[slot] void QToolBox::setCurrentWidget(QWidget *widget);
边栏推荐
猜你喜欢

【开发者必看】【push kit】推送服务典型问题合集2

Image information extraction DEM
![[HMS core] [FAQ] Collection of typical problems of push kit, AR Engine, advertising service, scanning service 2](/img/08/9f2c7d1ea704f234c2a1882f85df24.png)
[HMS core] [FAQ] Collection of typical problems of push kit, AR Engine, advertising service, scanning service 2

rhce笔记3

How to remove first character from php string

深度学习遇到报错Bug解决方法(不定时更新)

【AGC】质量服务2-性能管理示例

Mysql database query is very slow. Besides the index, what else can be caused?

How to remove last character from string in php

【HMS core】【FAQ】push kit、WisePlay DRM、Location Kit、Health Kit、3D Modeling Kit、SignPal Kit典型问题合集4
随机推荐
【HMS core】【FAQ】push kit, WisePlay DRM, Location Kit, Health Kit, 3D Modeling Kit, SignPal Kit Typical Questions Collection 4
ISELED---the new choice of ambient lighting scheme
Core Topics under Microservice Architecture (2): Design Principles and Core Topics of Microservice Architecture
TiUP FAQ
开源WebGIS架构
应用OPC解决方案实现控制系统数据的安全交换
L2-007 家庭房产(vector、set、map的使用)
【HMS core】【Media】【Video Editing Service】 The online material cannot be displayed, it is always in the loading state or the network is abnormal
How to implement timing tasks for distributed applications in Golang
FME实现CAD带属性转SHP数据方法
Sleuth+Zipkin (visualization) service link tracking
xxl-job源码解析(技术分享)
代码随想录笔记_哈希_1l两数之和
RISC-V calling conventions
经典实例分割模型Mask RCNN原理与测试
【开发者必看】【push kit】推送服务典型问题合集2
【HMS core】【FAQ】Account、IAP、Location Kit and HarmonyOS典型问题合集1
PMP每日一练 | 考试不迷路-7.30(包含敏捷+多选)
路遇又一个流量风口,民宿长期向好的逻辑选对了吗
服务器装好系统的电脑怎么分区