Questions tagged [qevent]

A QEvent is a class from the Qt toolkit which forms the base class of all other event classes.

QEvent objects act as containers for event parameters.

The Qt main event loop fetches native window system events from the event queue, translates them into QEvents, and sends the translated events to QObjects (which receive them via their event() function). It is also possible to manually create and send events.

Each subclass of QEvent contains additional parameters to describe that particular event type.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

120 questions
3
votes
1 answer

Is there any way to delay Qt QEvent?

Is there any way to delay proceed of QEvent in Qt? This pieces of code just show you what I want to do: QList waited_events; ... bool MyQWidget::event(QEvent * event) { if (event->type() == QEvent::KeyPress) { …
MikhailKrishtop
  • 492
  • 4
  • 17
3
votes
2 answers

How can I handle and filter events that are accepted and discarded deep inside some hierarchy without having to subclass every component on the way?

Assume following structure: MainWindow --->MySpecialWidget |-->QLineEdit |-->QSpinBox |-->QPushButton ---> Clicking on any on the above mentioned will cause its respective feature to…
Baumflaum
  • 749
  • 7
  • 20
3
votes
1 answer

Intercept widget move/resize before it happens

I'm using QMdiSubWindow, I want to capture any input which is attempting to modify the size/shape/position of the window and filter/modify the resulting position and size so that the widget is aligned to a grid. QResizeEvent seems to be too late,…
Troyseph
  • 4,960
  • 3
  • 38
  • 61
3
votes
2 answers

Qt keyPressEvent, "Hold", and keyReleaseEvent Handling with Buttons/Mouse Clicks

I am writing a Qt program to simulate a piece of hardware and I would like to simulate button press, hold, and release events. In my application, I'd like to handle input from both the keyboard and mouse clicks to make things convenient to the user…
GrandAdmiral
  • 1,348
  • 2
  • 24
  • 52
3
votes
1 answer

Ignore and propagate QWidget click events to the OS

I have a top-level parentless QWidget on top of which I have a bunch of other QWidgets(e.g. QPushButtons). I would like to make my QWidget act like it is transparent for mouse events. So when I click on the QWidget(but not on my buttons) I want my…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
3
votes
3 answers

Qt tab order keys

A user can step through the widgets of QtGUI via key "Tab" or via arrow keys "<-" and "->". Does anybody know how to disable the arrow keys for this purpose? I need the arrow keys for something else.
MichaelXanadu
  • 505
  • 1
  • 10
  • 25
3
votes
3 answers

QMainWindow stops receiving QEvent::UpdateRequest when user opens menu or resizes window

MyWindow which inherits from QMainWindow. MyWindow contains a QGLWidget that displays an animation. The problem is that the animation pauses whenever I open a menu or resize the window. The animation is implemented by calling…
jlstrecker
  • 4,953
  • 3
  • 46
  • 60
3
votes
1 answer

Is it necessary to call the event handler of the base class in subclasses?

Say I have QWidget::keyPressEvent(QKeyEvent *e) reimplemented in my subclass. Is it necessary to call the base class' implementation at the end of it? Example: MyWidget::keyPressEvent(QKeyEvent *e) { // my event handler... // now call…
daisy
  • 22,498
  • 29
  • 129
  • 265
2
votes
2 answers

How to emulate a QPushButton click in Qt with QEvents

I have a custom input device on and embedded system, and have to translate the input to proper events in Qt. In my current view I have a QListView and some QPushButtons. I use the following code in my widget. QKeyEvent * e = NULL; if (cmd.up.value) …
anr78
  • 1,308
  • 2
  • 17
  • 31
2
votes
1 answer

Qt. Declare custom QEvent type ONCE

I have a .h file with such code: const QEvent::Type MyOnEventType = QEvent::Type(QEvent::registerEventType( QEvent::User + 500 ) ); This header uses twice in application. I found a problem that in different places MyOnEventType have…
Maxim Korobov
  • 2,574
  • 1
  • 26
  • 44
2
votes
1 answer

Sending custom events in Qt between objects without relating them

I want to send some custom events between two Qt objects, but without making a relation between them. Normally in Qt we can send custom events (QApplication::sendEvent) but we must specify a pointer to receiver object! But when that two objects are…
pio
  • 21
  • 2
2
votes
1 answer

Should I check QEvent dynamic_cast result if I already checked event->type()?

QEvent has a type() member function which returns the event type as enum value. Should I check dynamic_cast result for QEvent* if I already checked event->type(). E.g. bool ClassName::eventFilter(QObject* obj, QEvent* event) { if (event->type()…
αλεχολυτ
  • 4,792
  • 1
  • 35
  • 71
2
votes
2 answers

Qt postEvent() and event filter

I want to filter some unwanted events sent to my worker QThread by QCoreApplication::postEvent(...), before it actually processed in event loop. When is event actually filtered by event filter: in postEvent() in the calling thread or later in…
2
votes
1 answer

Python example for Wacom tablets

Wacom has no official python SDK. Nevertheless, PyQt has a QTabletEvent that handles these tablets. Alas, I found no working python example of this. One can see a c++ example here. Can anyone please refer me to a python example?
Roi Yozevitch
  • 197
  • 3
  • 13
2
votes
0 answers

Why doesn't Qt3DRender::QPickEvent inherit from QEvent?

Qt3D introduces Qt3DRender::QPickEvent that can for instance be emitted when a 3D-object is clicked with the mouse. Why isn't it derived from QEvent, which should be "the base class of all event classes" according to its documentation?
oLen
  • 5,177
  • 1
  • 32
  • 48