<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 14 Dec 2018 at 21:22, Maurizio Berti <<a href="mailto:maurizio.berti@gmail.com">maurizio.berti@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><span class="gmail-m_4049839446743006230gmail-im">[sending again as I forgot to reply to the list]</span></div><div class="gmail_quote"><span class="gmail-m_4049839446743006230gmail-im"><br></span></div><div class="gmail_quote"><span class="gmail-m_4049839446743006230gmail-im">> is that about right (it does seem to work)?<div><br></div></span><div>Seems right.</div><div>The "name" argument of signals is not required as long as you use the same name for the attribute.<br></div><div><br></div><span class="gmail-m_4049839446743006230gmail-im"><br>> Right?  And then how do I emit that signal?  Is it like:<br>> styledItemDelegate.editStarted.connect(lambda: self.editStarted.emit(someItemWidget))<br>> Is that use of a lambda right (that's a Python/PyQt question)?<br>> And how do I get at from within the QListWidget which QListWidgetItem to pass as someItemWidget (that's probably a Qt question)?<br></span></div><div class="gmail_quote"><br></div><div class="gmail_quote">Not exactly. If you need to pass an argument to a function within a lambda, it has to be in the lambda arguments too, otherwise python will try to look for the argument name in the local scope and eventually raise an error if it doesn't exist.<br><br></div><div class="gmail_quote">Seeing your implementation I'd modify the original editStarted signal of the delegate and add a QModelIndex argument:</div><div class="gmail_quote"><span style="color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt;white-space:pre-wrap"><br></span></div><div class="gmail_quote"><span style="color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt;white-space:pre-wrap">    editStarted = QtCore.pyqtSignal(QtCore.QModelIndex)</span><br></div><div class="gmail_quote"><div><br></div><div>then emit the signal from the setEditorData method with its index argument:</div><div><br></div><div><span style="color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt;white-space:pre-wrap">    self.editStarted.emit(index)</span></div><div><br></div><div>At this point you can connect it with this lambda in the QListWidget init:</div><div><br></div><div><font face="monospace, monospace"><span class="gmail-m_4049839446743006230gmail-m_6120096286345341624gmail-m_-4564268010607243926gmail-hljs-selector-tag" style="white-space:pre-wrap">    styledItemDelegate</span><span class="gmail-m_4049839446743006230gmail-m_6120096286345341624gmail-m_-4564268010607243926gmail-hljs-selector-class" style="white-space:pre-wrap">.editStarted</span><span class="gmail-m_4049839446743006230gmail-m_6120096286345341624gmail-m_-4564268010607243926gmail-hljs-selector-class" style="white-space:pre-wrap">.connect</span><span style="white-space:pre-wrap">(</span><span class="gmail-m_4049839446743006230gmail-m_6120096286345341624gmail-m_-4564268010607243926gmail-hljs-selector-tag" style="white-space:pre-wrap">lambda index</span><span style="white-space:pre-wrap">: </span><span class="gmail-m_4049839446743006230gmail-m_6120096286345341624gmail-m_-4564268010607243926gmail-hljs-selector-tag" style="white-space:pre-wrap">self</span><span class="gmail-m_4049839446743006230gmail-m_6120096286345341624gmail-m_-4564268010607243926gmail-hljs-selector-class" style="white-space:pre-wrap">.editStarted</span><span class="gmail-m_4049839446743006230gmail-m_6120096286345341624gmail-m_-4564268010607243926gmail-hljs-selector-class" style="white-space:pre-wrap">.emit</span><span style="white-space:pre-wrap">(self.itemFromIndex(index))</span></font><br></div><div><br></div><div>In this way the the lambda will receive the index argument previously emitted, convert it to a list widget item and finally emit its own editStarted signal with the correct list widget item argument.</div><div><br></div><div>Regards,</div><div>Maurizio</div></div></div></div><div><br></div>-- <br><div class="gmail-m_4049839446743006230gmail_signature" dir="ltr">È 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></div>
</blockquote></div><br clear="all"><div class="gmail_default" style="font-family:tahoma,sans-serif">@Maurizio Berti</div><div class="gmail_default" style="font-family:tahoma,sans-serif">Thank you so much for replying.  I get the gist now.  I will try implementing next week!</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">One thing I didn't like/expect: your Qt reply is that same as at the forum (so I accept that's the way to do it now), you use the <font face="monospace,monospace">QStyledItemDelegate </font>to get the item being edited (from the <font face="monospace,monospace">QIndex</font> parameter), I expected that to be doable in the <font face="monospace,monospace">QListWidget </font>class by (somehow) it knowing which item was being edited instead, but it seems that's not the case.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Grazie/Arrivederci/Ciao :)</div><br>-- <br><div class="gmail_signature" dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><span style="font-family:tahoma,sans-serif">Kindest,</span></div><div><span style="font-family:tahoma,sans-serif">Jonathan</span></div></div></div></div></div></div></div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
        <tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
                <td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank" style="color:#4453ea">www.avast.com</a>
                </td>
        </tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>