> I'm beginning to look at PySide as a replacement for PyQt. The transition seems pretty straightforward so far, except for my QEvent subclasses. In PyQt, I defined new events like so:
>
> from PyQt4.QtCore import QEvent
>
> (EVENT_1,
> EVENT_2,
> EVENT_3) = range(QEvent.User, QEvent.User+3)
>
> With PySide however, this trhows an exception:
>
> TypeError: 'PySide.QtCore.QEvent' called with wrong argument types:
> PySide.QtCore.QEvent(int)
> Supported signatures:
> PySide.QtCore.QEvent(PySide.QtCore.QEvent.Type)
>
> What is the correct way of creating new QtCore.QEvent.Type s in PySide?
>
> Thanks,
>
I forgot to mention. System specs:
Python 2.7
Qt 4.7.1
PySide 1.0.0 beta 4
_______________________________________________
PySide mailing list
PyS...@lists.openbossa.org
http://lists.openbossa.org/listinfo/pyside
If you sum a enum value plus a number the result will be a number.
Every enum is convertible to a number, but not all enums are convertible to
numbers because the enum values are a subset of all possible numbers.
About QEvent, this is a design flaw in Qt, in C++ the user must do a
static_cast from int to QEvent::Type to be able to create your own events, so
in Python you must do:
QEvent(QEvent.Type(someInt))
instead of
QEvent(someInt)
We don't do implicit casts from ints to enums as PyQt4 does because those
casts are completely unsafe and passing unsafe values to C++ could easily
result in nice segfaults :-).
> Thanks,
>
> Grant Limberg
--
Hugo Parente Lima
INdT - Instituto Nokia de Tecnologia
Thanks for the info. Wrapping the value with QEvent.QType(int) works fine. I'm sure there are a few other places in my codebase that use ints in the place of Enums so I'll be on the lookout for this.
Grant Limberg
from PyQt4.QtCore import QEvent
(EVENT_1,
EVENT_2,
EVENT_3) = range(QEvent.User, QEvent.User+3)
With PySide however, this trhows an exception:
TypeError: 'PySide.QtCore.QEvent' called with wrong argument types:
PySide.QtCore.QEvent(int)
Supported signatures:
PySide.QtCore.QEvent(PySide.QtCore.QEvent.Type)
What is the correct way of creating new QtCore.QEvent.Type s in PySide?
Thanks,
Grant Limberg