当前位置:   article > 正文

qtabwidget tab隐藏_显示/隐藏QTabWidget上的子选项卡

qtabwidget不显示选项卡

Assuming I have a QTabWidget that contains 5 sub-tabs. Now I want to show/hide a sub-tab in one of 5 sub-tabs by following code

ui->twListTabs->widget(0)->hide(); // Hide first sub-tab

But this didn’t work for me. Do you have any solutions?

Thanks!

解决方案

You only have the option to use:

void QTabWidget::removeTab(int index)

You need to store the pointer to the QWidget in the tab so that you can later insert it.

You could e.g. do something like:

class TabWidget : public QTabWidget

{

Q_OBJECT

enum tabwidgets {tabwidget1,tabwidget2,...,number_of_tabwidgets};

QWidget* widgets_[number_of_tabwidgets];

public:

TabWidget(QWidget* parent = 0) : QWidget(parent)

{

for(int i(0); i < number_of_tabwidgets; ++i)

{

switch(i)

{

case tabwidget1:

insertTab(i,widgets_[i] = new TabWidget1,QString::number(i));

....

}

}

}

};

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/962339
推荐阅读
相关标签
  

闽ICP备14008679号