<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 May 2018 at 10:12, Florian Bruhin <span dir="ltr"><<a href="mailto:me@the-compiler.org" target="_blank">me@the-compiler.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Thu, May 17, 2018 at 09:50:13AM +0100, J Barchan wrote:<br>
> ​I'm not sure whether ​I am hijacking a relevant thread, or whether this<br>
> can already be done, but I would like to know how to (easily) get the<br>
> symbolic string for an ItemDataRole constant:<br>
> <br>
> class MySqlQueryModel(<wbr>QSqlQueryModel):<br>
>     def data(self, index: QtCore.QModelIndex, role:<br>
> <div style="font-family:tahoma,sans-serif;display:inline" class="gmail_default">​​</div>QtCore.Qt.ItemDataRole=QtCore.<wbr>Qt.DisplayRole) -> typing.Any:<br>
>         print(role)<br>
> <br>
> ​How do I get to print that role as, say, "DisplayRole" instead of as 0,<br>
> for debugging?​<br>
<br>
</span>I wrote something to do that here:<br>
<a href="https://github.com/qutebrowser/qutebrowser/blob/v1.3.0/qutebrowser/utils/debug.py#L96-L132" rel="noreferrer" target="_blank">https://github.com/<wbr>qutebrowser/qutebrowser/blob/<wbr>v1.3.0/qutebrowser/utils/<wbr>debug.py#L96-L132</a><br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
Florian<br>
<br>
-- <br>
<a href="https://www.qutebrowser.org" rel="noreferrer" target="_blank">https://www.qutebrowser.org</a> | <a href="mailto:me@the-compiler.org">me@the-compiler.org</a> (Mail/XMPP)<br>
   GPG: 916E B0C8 FD55 A072 | <a href="https://the-compiler.org/pubkey.asc" rel="noreferrer" target="_blank">https://the-compiler.org/<wbr>pubkey.asc</a><br>
         I love long mails! | <a href="https://email.is-not-s.ms/" rel="noreferrer" target="_blank">https://email.is-not-s.ms/</a><br>
</div></div></blockquote></div><br></div><div class="gmail_extra"><div style="font-family:tahoma,sans-serif" class="gmail_default">​Dear Florian,</div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default">Thanks!  Your <span style="font-family:monospace,monospace">qenum_key()</span> looks promising <i>except for</i>:​</div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default"><ol><li>I cannot find anything suitable to pass in as `base`, e.g.<br><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">qenum_key(QtCore.Qt, role, <span style="color:rgb(102,0,153)">klass</span>=QtCore.Qt.ItemDataRole)</pre>does not work.  I don't understand what it is I need here which has a <span style="font-family:monospace,monospace">base.staticMetaObject</span>?<br></li><li>Is this whole principle going to work for <span style="font-family:monospace,monospace">QtCore.Qt.ItemDataRole</span>?  So far as I can see, it's not some kind of <span style="font-family:monospace,monospace">enum</span> in PyQt, it's just a class derived from <span style="font-family:monospace,monospace">int</span> with a bunch of sundry member variables for various values.<br></li></ol></div>-- <br><div class="gmail_signature"><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>