I want to debug event handling code and would like to convert QEvent::Type
enum's value to a human-readable string. QEvent
has a Q_GADGET
macro, so presumably there's a way of pulling that off?
相关问题
- QML: Cannot read property 'xxx' of undefin
- QTextEdit.find() doesn't work in Python
- QT Layouts, how to make widgets in horizontal layo
- QT GUI freezes even though Im running in separate
- QGraphicsView / QGraphicsScene size matching
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Is there a non-java, cross platform way to launch
- How to get a settings storage path in a cross-plat
- Why doesn't valgrind detect a memory leak in m
- QTreeView remove decoration/expand button for all
- qt界面拥挤
- how do I correctly return values from pyqt to Java
Recent versions of Qt do the right thing when outputting events to the debug stream, so the below isn't neccessary. If you get an error similar to
warning C4273: 'operator <<' : inconsistent dll linkage
, it means that your version of Qt already supports this without need for the code below.The
Q_GADGET
macro adds aQMetaObject staticMetaObject
member to the class. The static metaobject's definition is generated by moc, and it - in the case ofQEvent
- contains the enumeration information.Below is an example of how to leverage that to give a more reasonable
QDebug
output of events.Use example:
Q_GADGET and Q_ENUM can be combined to get the following template:
Example: