Moving child widgets between QTabWidgets?
Maurizio Berti
maurizio.berti at gmail.com
Tue Jan 17 21:25:25 GMT 2023
If it throws that error, it's because the widgets (or their parent) have
been deleted.
Unfortunately, your code is insufficient to actually understand where the
issue is, and, by the way, it also has important issues: first of all the
second for loop is wrong (new_tab_widget is a widget, so that will throw an
exception), and using removeTab with the number of a counter is wrong, as
you'll always get even numbered items, if you want to remove all widgets,
always use removeTab(0).
I suggest you to provide a valid minimal reproducible example.
Maurizio
Il giorno mar 17 gen 2023 alle ore 14:11 Matic Kukovec <
kukovecmatic at hotmail.com> ha scritto:
> 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
>
--
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230117/4083852b/attachment-0001.htm>
More information about the PyQt
mailing list