質問

I made my GUI using Qt Designer and I have a QTabWidget with multiple tabs. My tabs contain specific tools that are used in my app. Now I would like to set my tabs closable and movable so I could save the order of my tabs and load it when the app starts. The problem is, I don't know how to reorder my tabs when the application loads. Is this possible?

役に立ちましたか?

解決

You can move tabs by accessing the QTabBar object associated with the QTabQidget

QTabBar has a method moveTab() which will allow you to reorder tabs.

So you would do something like my_tab_widget.tabBar().moveTab(old_position, new_position) where old_position and new_position are integers which specify the tab to move and the position to move it to respectively.

Lots of details in the c++ documentation (it translates to python pretty easily). See QTabBar docs and QTabWidget docs

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top