qevent

Is there a cleaner way to register Qt custom events?

大城市里の小女人 提交于 2019-12-03 14:56:04
I need to create several custom event classes for a Qt application. Right now, it looks like I will need to implement the following event type registration code for each event class: class MyEvent : public QEvent { public: MyEvent() : QEvent(registeredType()) { } static QEvent::Type eventType; private: static QEvent::Type registeredType(); } QEvent::Type MyEvent::eventType = QEvent::None; QEvent::Type MyEvent::registeredType() { if (eventType == QEvent::None) { int generatedType = QEvent::registerEventType(); eventType = static_cast<QEvent::Type>(generatedType); } return eventType; } Any

QStateMachine - QMouseEvent

谁说我不能喝 提交于 2019-12-02 16:23:40
问题 In another question you tell me to use QStateMachine. I'm new to Qt and it's the first time i use the objects so I make a lot of logical mistake, so using QStateMachine it's a big problem... It's the only way to do thath ? I try to explain my program: I want to create a card's game and in the previous version I've used an old graphics library with this sequence of commands: -> print cards on the scene -> wait for a mouse input (with a do-while) -> if(isMouseClick(WM_LBUTTONDOWN)) -> if(mouse

QStateMachine - QMouseEvent

孤街醉人 提交于 2019-12-02 08:25:47
In another question you tell me to use QStateMachine. I'm new to Qt and it's the first time i use the objects so I make a lot of logical mistake, so using QStateMachine it's a big problem... It's the only way to do thath ? I try to explain my program: I want to create a card's game and in the previous version I've used an old graphics library with this sequence of commands: -> print cards on the scene -> wait for a mouse input (with a do-while) -> if(isMouseClick(WM_LBUTTONDOWN)) -> if(mouse position is on the first card) -> select that card. So i wish to do the same thing with QGraphics. In

How to get human-readable event type from QEvent?

与世无争的帅哥 提交于 2019-12-01 03:24:17
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? 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 a QMetaObject staticMetaObject member to the class. The static metaobject's definition is

How to get human-readable event type from QEvent?

天大地大妈咪最大 提交于 2019-11-30 22:54:51
问题 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? 回答1: 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

Why pressing of “Tab” key emits only QEvent::ShortcutOverride event?

Deadly 提交于 2019-11-30 09:37:56
Background Hi guys. I've made a custom widget with QLineEdit and several QPushButtons to use it with custom item delegate: class LineEditor : public QWidget { public: explicit LineEditor(QWidget *parent = 0) : QWidget(parent) { setLayout(new QHBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); layout()->setSpacing(0); QLineEdit *edit = new QLineEdit(this); layout()->addWidget(edit); layout()->addWidget(new QPushButton(this)); layout()->addWidget(new QPushButton(this)); setFocusProxy(edit); } }; class PropertyDelegate : public QItemDelegate { public: QWidget *createEditor(QWidget *parent,