<div dir="ltr">I can confirm the same with PyQt 6.2.2 and Python 3.9.5.<div>The problem is obviously not the delegate, but setModel() itself, which returns True on PyQt5 but False on PyQt6.</div><div><br></div><div>Maurizio</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno gio 6 gen 2022 alle ore 18:06 Phil Thompson <<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.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">On 05/01/2022 19:21, James Evans wrote:<br>
> QTableWidget, QTreeWidget, and QListWidget use custom ItemModel classes <br>
> that,<br>
> when coupled with a custom delegate, cannot be properly modified.<br>
> <br>
> When QTreeWidget calls the delegate for a specific item, it passes a<br>
> 'QAbstractItemModel*' pointer to the delegate 'setModelData' method. <br>
> Inside the<br>
> 'setModelData' method, the model data is typically updated with a call <br>
> to<br>
> 'model.setData( . )' which will eventually trigger an 'itemChanged' <br>
> signal to be<br>
> emitted by the QTreeWidget.<br>
> <br>
> The problem arises because the ItemModel classes used by these widgets <br>
> are not<br>
> part of the public Qt API. If the QTreeWidget model QTreeModel was <br>
> part of the<br>
> public API, then sip would have actually passed in a pointer to the <br>
> derived<br>
> QTreeModel class, and everything would work fine. Instead calling<br>
> 'model.setData' results in a C++ call like so: <br>
> "::QAbstractItemModel::setData( .<br>
> )", which will always fail (as designed).<br>
> <br>
> The funny thing is, that this actually used to work (for many years) <br>
> before I<br>
> recently updated the version of the tools I am using.<br>
> Qt/PyQt: 5.15.1 --> 6.2.2<br>
> GCC: 10.2.0 --> 11.2.0<br>
> <br>
> I have attached a script that I can run successfully in my PyQt5 <br>
> environment,<br>
> but fails under the PyQt6 environment.<br>
> NOTE: I wrote this script to highlight the problem, not as an example <br>
> of good<br>
> code, so no judgement please. :)<br>
> <br>
> --James<br>
<br>
Define "fails". I get the same output for PyQt5 and PyQt6.<br>
<br>
Phil<br>
</blockquote></div><br clear="all"><div><br></div>-- <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>