Qt 设置选项卡栏
Qt Setting A TabBar
我正在使用Qt框架制作应用程序,遇到了一个问题:我像这样定义一个 TabWidget
QTabWidget *armaTab = new QTabWidget();
armaTab->setContentsMargins(0, 0, 0, 0);
armaTab->setTabPosition(QTabWidget::North);
armaTab->setObjectName(QString::fromUtf8("armaTab"));
然后我尝试像这样添加一个 QTabBar:
QTabBar *tabBar = new QTabBar();
tabBar->setContentsMargins(0, 0, 0, 0);
tabBar->setFont(*font);
tabBar->setObjectName(QString::fromUtf8("armaTabBar"));
armaTab->setTabBar(tabBar);
我收到此错误:
error: 'void QTabWidget::setTabBar(QTabBar*)' is protected
error: within this context
有人可以解释一下我的错误在哪里吗?
这只是意味着您必须注意才能访问组件: 从文档:
void QTabWidget::setTabBar ( QTabBar * tb ) [protected]
将对话框的 QTabBar 标题替换为选项卡栏 tb。请注意,必须在添加任何选项卡之前调用它,否则行为未定义。
我认为您可以简单地对 QTabWidget 进行子类以访问受保护的成员......
相关文章:
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 通过选项卡的文本设置QTabWidget顺序
- 如何在提升程序选项中设置矢量<矢量>的默认值<string>
- 错误:必须设置CMake工具才能生成.在工具包选项中配置CMake工具
- 设置QTabWidget中各个选项卡的颜色
- 在 QTabWidget 中动态设置单个选项卡的样式
- 提升::P设置选项无法使所有参数都处于位置状态
- 设置复选框选项C++
- 我可以通过设置工具链文件来替换调用 cmake -G<generator> 选项和调用 vcvarsall.bat吗?
- 在现代CMAKE中设置全球选项
- 如何在 libgit2 中设置结帐选项以使其表现得像"git checkout"
- 转到特定页面后,如何将滑动视图的当前索引设置为选项卡栏"by reference"的当前索引?
- 如何在 QTabWidget 中为选项卡设置布局
- 使用 API 而不是全局配置文件设置 OSM 配置选项
- VS2017:如何在不破坏我设置的过滤器的情况下,以.vcxproj编写每个文件的选项?
- boost::p rogram_options:是否可以将一个选项设置为另一个选项的默认值
- 如何设置Clang-Format样式选项,以在捕获前保持不合格
- Winapi设置活动选项卡控件
- 如何设置 windows 文件打开对话框筛选器以包含"必须完成"选项
- 将set选项设置为默认值