<div dir="ltr"><div>If it throws that error, it's because the widgets (or their parent) have been deleted.</div><div>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).<br></div><div>I suggest you to provide a valid minimal reproducible example.</div><div><br></div><div>Maurizio<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno mar 17 gen 2023 alle ore 14:11 Matic Kukovec <<a href="mailto:kukovecmatic@hotmail.com">kukovecmatic@hotmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg3076459795999726911">




<div dir="ltr">
<div><span style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">HI,</span></div>
<div><br>
</div>
<div>What is the PyQt idiomatic way of moving a widget from one QTabWidget to another?</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
I have tried this:</div>
<blockquote style="margin-top:0px;margin-bottom:0px">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)"><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">widgets = []</span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">for i in range(old_tab_widget.count()):</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<div><span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">    widgets.append((old_tab_widget.widget(i), old_tab_widget.tabText(i)))</span></div>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">    old_tab_widget.removeTab(i)</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<br>
</div>
<span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">for widget, tab_text in new</span><span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">_tab_widget</span><span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">:</span>
<div><span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">   
</span><span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">new_tab_widget</span><span style="font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">.addTab(widget, tab_text)</span></div>
</blockquote>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
but this throws errors for example for QTreeView widgets like this:</div>
<blockquote style="margin-top:0px;margin-bottom:0px">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span></span><span>...<br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span>    new_tab_widget</span><span></span>.addTab(widget, tab_text)<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
RuntimeError: wrapped C/C++ object of type TreeExplorer has been deleted</div>
</blockquote>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
(TreeExplorer is my subclassed QTreeView)<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
Thanks</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
Matic<br>
</div>
</div>

</div></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div>