简体   繁体   中英

In pyQT5 how do you conditionally hide a tab in a widget?

I've created a widget and I've applied several form layouts to tabs within the widget. I would like to make some tabs available based on some boolean flags.

I've tried tab_my_tab.setEnabled(False) which disables the content of the tab, but it doesn't hide the tab. I'd like it if the tab is completely hidden.

I've found the solution to my question. I was able to hide one or more tabs by using the setTabVisible(index, bool) method on the QTabWidget() .

To hide multiple tabs you have to start hiding the highest index number tab first before hiding the lower index number tabs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM