<html><head>
<style id="css_styles">
blockquote.cite { margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc }
blockquote.cite2 {margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc; margin-top: 3px; padding-top: 0px; }
a img { border: 0px; }
table { border-collapse: collapse; }
li[style='text-align: center;'], li[style='text-align: center; '], li[style='text-align: right;'], li[style='text-align: right; '] { list-style-position: inside;}
body { font-family: Calibri; font-size: 12pt; }
.quote { margin-left: 1em; margin-right: 1em; border-left: 5px #ebebeb solid; padding-left: 0.3em; }
a.em-mention[href] { text-decoration: none; color: inherit; border-radius: 3px; padding-left: 2px; padding-right: 2px; background-color: #e2e2e2; }
</style>
</head>
<body>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: 0 0 0 40px; border: none; 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></body></html>