<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof"><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 class="elementToProof"><br>
</div>
<div class="elementToProof">What is the PyQt idiomatic way of moving a widget from one QTabWidget to another?</div>
<div class="elementToProof" 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:0;margin-bottom:0" class="ContentPasted6">
<div class="elementToProof ContentPasted0 ContentPasted4" 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 class="elementToProof ContentPasted0 ContentPasted4" 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 class="elementToProof ContentPasted0" 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 class="elementToProof ContentPasted0" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<div class="ContentPasted0 ContentPasted1 ContentPasted2"><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 class="elementToProof ContentPasted0 ContentPasted3" 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 class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5" 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 class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5" 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:0;margin-bottom:0">
<div class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5 ContentPasted7" 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 class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5 ContentPasted7" 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 class="ContentPasted7">
</div>
<div class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5 ContentPasted7" 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 class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5 ContentPasted7 ContentPasted8" 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 class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5 ContentPasted7" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5 ContentPasted7" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thanks</div>
<div class="elementToProof ContentPasted0 ContentPasted3 ContentPasted5 ContentPasted7" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Matic<br>
</div>
</body>
</html>