Moving child widgets between QTabWidgets?

Matic Kukovec kukovecmatic at hotmail.com
Tue Jan 17 13:11:41 GMT 2023


HI,

What is the PyQt idiomatic way of moving a widget from one QTabWidget to another?
I have tried this:

widgets = []
for i in range(old_tab_widget.count()):
    widgets.append((old_tab_widget.widget(i), old_tab_widget.tabText(i)))
    old_tab_widget.removeTab(i)

for widget, tab_text in new_tab_widget:
    new_tab_widget.addTab(widget, tab_text)

but this throws errors for example for QTreeView widgets like this:
...
    new_tab_widget.addTab(widget, tab_text)
RuntimeError: wrapped C/C++ object of type TreeExplorer has been deleted
(TreeExplorer is my subclassed QTreeView)

Thanks
Matic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230117/970dc1b1/attachment.htm>


More information about the PyQt mailing list