On Thursday 27 January 2011 19:05:49 Grant Limberg wrote: > 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?
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
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ PySide mailing list PySide@lists.openbossa.org http://lists.openbossa.org/listinfo/pyside