[PyQt] Can I use custom enumerations for custom pyqtProperty's?

Phil Thompson phil at riverbankcomputing.com
Wed Mar 9 15:42:15 GMT 2016


On 19 Feb 2016, at 10:31 pm, Kyle Altendorf <sda at fstab.net> wrote:
> 
> 
> On 2016-02-19 15:55, Phil Thompson wrote:
>> On 19/02/2016 5:41 pm, Kyle Altendorf wrote:
>>> I am making a set of widgets which are usable in Qt Designer.  It
>>> works great and was fairly easy.  I am quite pleased.  :]  I have now
>>> added a couple of QString properties as well and also want
>>> enumeration/combobox properties such as shows for the focusPolicy
>>> QWidget property.  Is this possible?  If so how?
>> PyQt implements Q_ENUM so you can experiment with that.
> 
> Thanks for the quick reply.  I tried a few different permutations...  of Q_ENUMS (note that I have an 'S' at the end, I didn't notice your singular Q_ENUM at first).

My typo - it should be Q_ENUMS.

> https://github.com/altendky/st/commits/8133819c0421d0f39a1d22c0e31fe7a46e304d02
> 
> The commits provide descriptions of how each didn't work and the console output from Qt Designer.  In short, the closest it came to working was no errors and a property with a numeric spinbox.  No textual enumeration names.
> 
> I do see that Q_ENUM (without the 'S') is a thing.
> 
> http://doc.qt.io/qt-5/qobject.html#Q_ENUM
> 
> I searched the PyQt source (5.5.1 and PyQt-gpl-5.5.2-snapshot-796954fadf1e) but found no singular reference, only Q_ENUMS.  Is it hidden somewhere or am I reading too much into the missing 'S'?
> 
> I did notice the PyQt5 metaobjects page but didn't notice anything different there.
> 
> http://pyqt.sourceforge.net/Docs/PyQt5/metaobjects.html
> 
> Any other pointers would be great.  Thanks.

It should work in tonight's PyQt5 snapshot.

Phil


More information about the PyQt mailing list