[PyQt] Some QEvent::Type enum elements cannot be accessed by names

Yamamoto, Mitsuo yamamoto.mitsuo at jaxa.jp
Fri Feb 6 10:27:51 GMT 2015


Hello PyQt community,

I have recently noticed the matter of the subject. I don't know
if it is a bug or an expected behaviour. Searching the keywords
"ContentsRectChange" and "QEvent" on Gmane and The Mail Archive
didn't give me a clue. If it is unexpected, I want to report it.

They are as follows:

PyQt GPL v5.4 for Python v3.4 (x64) with Python 3.4.2 on Windows 7;
  QEvent.ContentsRectChange,
  QEvent.EnterEditFocus,
  QEvent.LeaveEditFocus,
  QEvent.NonClientAreaMouseButtonDblClick,
  QEvent.NonClientAreaMouseButtonPress,
  QEvent.NonClientAreaMouseButtonRelease,
  QEvent.NonClientAreaMouseMove,
  QEvent.MacSizeChange,
  QEvent.NativeGesture,
  QEvent.ThreadChange

PyQt4-4.10.1-13.el7.x86_64 with python-2.7.5-16.el7.x86_64 on CentOS 7;
  QEvent.ApplicationStateChange,
  QEvent.ContentsRectChange,
  QEvent.EnterEditFocus,
  QEvent.Expose,
  QEvent.FocusAboutToChange,
  QEvent.InputMethodQuery,
  QEvent.LeaveEditFocus,
  QEvent.NonClientAreaMouseButtonDblClick,
  QEvent.NonClientAreaMouseButtonPress,
  QEvent.NonClientAreaMouseButtonRelease,
  QEvent.NonClientAreaMouseMove,
  QEvent.MacSizeChange,
  QEvent.NativeGesture,
  QEvent.OrientationChange,
  QEvent.ReadOnlyChange,
  QEvent.ScrollPrepare,
  QEvent.Scroll,
  QEvent.ThreadChange,
  QEvent.TouchCancel

Trying to access enum values through these names raises AttributeError.
Even so, values for those names seem encapsulated in QEvent objects
when events occur and I can access them through QEvent::type(). I at
least check that for ContentRectChange.

The attached zip archive includes the code I used to confirm that.

'experiments_handling_QEvent_ContentsRectChange.py' prints inaccessible
QEvent::Type enum elements using try-except statement. Then it shows
simple GUI. When you double-click the window-like widget at the centre,
it evokes ContentsRectChange event and it handles it.

You can run it with PyQt5, PyQt4, or PySide if they are installed on
the system and you designate the binding package on the command line.

I extracted the keyword list to check against from
<http://doc.qt.io/qt-5/qevent.html#Type-enum> and generated Python
list programmatically. I think there is no excess or deficiency in
the list I used on this experiment.

It seems that some of the missing symbols don't exitst in the PyQt source
files. I don't know if that causes this to happen. This is the first
time I investigate the source tree and I have only a vague understanding
of what SIP is and what it actually does.

Anyway, 'search_qevent_type_enum_keywords.py' searches the keywords
of the enum elements such as MouseButtonDblClick and reports what's
not found in the sources whose extensions are cpp, h, py, and sip in
the source tree.

To run this, please put it the root of the source tree or, when run
it from other directories, set the source tree directory on the command
line.

The keywords below are the results.

ContentsRectChange,
EnterEditFocus,
LeaveEditFocus,
NonClientAreaMouseButtonDblClick,
NonClientAreaMouseButtonPress,
NonClientAreaMouseButtonRelease,
NonClientAreaMouseMove,
MacSizeChange,
and ThreadChange are not found in both the source files of
PyQt-gpl-5.4 and PyQt-gpl-5.4.1-snapshot-bcb234196361.

ApplicationStateChange,
ContentsRectChange,
EnterEditFocus,
LeaveEditFocus,
NonClientAreaMouseButtonDblClick,
NonClientAreaMouseButtonPress,
NonClientAreaMouseButtonRelease,
NonClientAreaMouseMove,
MacSizeChange,
NativeGesture,
ReadOnlyChange,
and ThreadChange are not found in both the source files of
PyQt-win-gpl-4.11.3 and PyQt-win-gpl-4.11.4-snapshot-e270102197b1.

I wish I don't have a wrong idea and waste your time.

Best regards,

-- 
Yamamoto, Mitsuo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: experiment_code.zip
Type: application/x-zip-compressed
Size: 4950 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150206/635ec112/attachment-0001.bin>


More information about the PyQt mailing list