qt-events

qt mouse event filter

天涯浪子 提交于 2020-01-05 16:48:33
问题 I have a QWidget with a QGraphicsView and a push button. The QGraphicsView has to take mouse press and release events to detect a swipe .At the same time push button should run a small function on clicked. I used an event filter in the QWidget to detect the mouse events. bool Widget::eventFilter(QObject * obj, QEvent * event) { // Capturing keyboard events for moving if( event->type() == QEvent::KeyPress ) { //Do something } //Capturing mouse events for swipe else if( event->type() == QEvent:

qt mouse event filter

杀马特。学长 韩版系。学妹 提交于 2020-01-05 16:48:08
问题 I have a QWidget with a QGraphicsView and a push button. The QGraphicsView has to take mouse press and release events to detect a swipe .At the same time push button should run a small function on clicked. I used an event filter in the QWidget to detect the mouse events. bool Widget::eventFilter(QObject * obj, QEvent * event) { // Capturing keyboard events for moving if( event->type() == QEvent::KeyPress ) { //Do something } //Capturing mouse events for swipe else if( event->type() == QEvent:

Propagate QML events to C++

柔情痞子 提交于 2019-12-23 13:29:08
问题 I would like to propagate event from a QML signal handler to C++ procedure but don't know how to pass the "event object". Take a look at this situation and pay particular attention to SomeType . First I create a custom QML item with a slot that can be called from QML: class Tool : public QQuickItem { . . . public slots: virtual void onMousePositionChanged(SomeType *event); } Then, in QML, I create a MouseArea and an instance of my custom object to which I wanto to propagate events to.

Using Hover Events

随声附和 提交于 2019-12-11 02:06:31
问题 I am having trouble capturing the hover enter and hover leave events in a QGraphicsRectItem . I have subclassed this object, and reimplemented the hover enter and hover leave handlers... or at least I think I have. I also set accepts hover event to true in the constructor. The event is never fired, however. Breakpoints inside the handlers are never hit. Here is the class: #include "qhgraphicsrectitem.h" QhGraphicsRectItem::QhGraphicsRectItem(QGraphicsRectItem *parent) : QGraphicsRectItem