<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">>
<font face="Cascadia Mono" size="1" style="font-size:13.3px" class="gmail-">QKeyCombination(Qt.KeyboardModifier.ControlModifier, key=65)</font> <br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">You can't pass integer for enum, either use</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">
<font face="Cascadia Mono" size="1" style="font-size:13.3px" class="gmail-">QKeyCombination(Qt.KeyboardModifier.ControlModifier, key=Qt.Key.Key_A)</font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><font face="Cascadia Mono" size="1" style="font-size:13.3px" class="gmail-"><br></font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><font face="Cascadia Mono" size="1" style="font-size:13.3px" class="gmail-">or</font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><font face="Cascadia Mono" size="1" style="font-size:13.3px" class="gmail-"><br></font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">
<font face="Cascadia Mono" size="1" style="font-size:13.3px" class="gmail-">QKeyCombination(Qt.KeyboardModifier.ControlModifier, key=Qt.Key(65))</font>
</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Dec 18, 2024 at 12:38 PM John F Sturtz <<a href="mailto:john@sturtz.org">john@sturtz.org</a>> wrote:<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="msg-8982048815171390447">
<div>Hi again.<div><br></div><div>I am trying to port some <font face="Cascadia Mono" style="font-size:11pt" size="2">PyQt5</font> code to <font face="Cascadia Mono" style="font-size:13.3px" size="1">PyQt6</font>, and am running into confusion using the <font face="Cascadia Mono" style="font-size:14.7px" size="2">Qt.KeyboardModifier</font> <font face="Cascadia Mono" size="1" style="font-size:13.3px">enum</font> objects. I think (hope) the answer to this question would probably enlighten me more generally as to what I'm misunderstanding:</div><div><br></div><div>Suppose I want to manually construct a <font face="Cascadia Mono" size="1" style="font-size:13.3px">QKeyCombination</font> object. This:</div><div><br></div><div><font face="Cascadia Mono" size="1" style="font-size:13.3px"> QKeyCombination(Qt.KeyboardModifier.ControlModifier, key=65)</font></div><div><font face="Cascadia Mono" size="1" style="font-size:13.3px"><br></font></div><div>fails, telling me that argument 1 has unexpected type 'KeyboardModifier'.</div><div><br></div><div>Indeed the Qt documentation for <font face="Cascadia Mono" size="1" style="font-size:13.3px">QKeyCombination</font> says that argument 1 should be of type <font face="Cascadia Mono" size="1" style="font-size:13.3px">Qt::KeyboardModifiers</font> (plural). And that the type of <font face="Cascadia Mono" size="1" style="font-size:13.3px">Qt::KeyboardModifier</font> is <font face="Cascadia Mono" size="1" style="font-size:13.3px">enum</font>, and that of <font face="Cascadia Mono" size="1" style="font-size:13.3px">Qt::KeyboardModifiers</font> (plural) is <font face="Cascadia Mono" size="1" style="font-size:13.3px">flags</font>.</div><div><br></div><div>It also says 'The <font face="Cascadia Mono" size="1" style="font-size:13.3px">KeyboardModifiers</font> type is a typedef for <font face="Cascadia Mono" size="1" style="font-size:13.3px">QFlags<KeyboardModifier></font>. It stores an OR combination of <font face="Cascadia Mono" size="1" style="font-size:13.3px">KeyboardModifier</font> values.'</div><div><br></div><div>I think I understand (on some level) that the concept of <font face="Cascadia Mono" size="1" style="font-size:13.3px">QFlags</font> in Qt is not used in PyQt (anyway, I can't find anything called <font face="Cascadia Mono" size="1" style="font-size:13.3px">QFlags</font> in PyQt). But then I'm beating my head against the wall trying to figure out: What <i>does</i> the <font face="Cascadia Mono" size="1" style="font-size:13.3px">QKeyCombination</font> constructor want for its first argument?</div><div><br></div><div>The PySide6 documentation for <font face="Cascadia Mono" size="1" style="font-size:13.3px">QKeyCombination</font> (unhelpfully) says:</div><div>
</div><blockquote style="margin:0px 0px 0px 40px;border:medium;padding:0px"><div><font face="Cascadia Mono" size="1" style="font-size:13.3px">__init__(modifiers[, key=Qt.Key_unknown])
</font></div><div><br></div><div> Parameters:
</div><div> <font face="Cascadia Mono" size="1" style="font-size:13.3px">modifiers</font> – Combination of <font face="Cascadia Mono" size="1" style="font-size:13.3px">KeyboardModifier</font> </div><div> <font face="Cascadia Mono" size="1" style="font-size:13.3px">key</font> – Key </div></blockquote><div><br></div><div>What sort of 'combination'? In what way do I combine <font face="Cascadia Mono" size="1" style="font-size:13.3px">KeyboardModifier</font> objects so as to satisfy <font face="Cascadia Mono" size="1" style="font-size:13.3px">QKeyCombination</font>'s demand for an object of type <font face="Cascadia Mono" size="1" style="font-size:13.3px">KeyboardModifiers</font> (plural) as the first argument?</div><div><br></div><div>Thanks again!</div><div><br></div><div>/John</div></div></div></blockquote></div>