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
15
votes
2 answers

How to get human-readable event type from QEvent?

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?
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
9
votes
1 answer

Is there a cleaner way to register Qt custom events?

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() :…
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281
9
votes
1 answer

How to detect that my application lost focus in Qt?

I'm displaying a popup window when the mouse cursor is over a certain widget and I'd like to hide this popup when the mouse leaves the widget. To do it, I reimplemented leaveEvent(). This seems to work in all cases except when switching to another…
Michal
  • 565
  • 5
  • 15
9
votes
1 answer

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

Background 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…
fasked
  • 3,555
  • 1
  • 19
  • 36
8
votes
1 answer

Cancel closing QWidget after clicking close button

Is it possible to keep a QWidget open after close button clicked? Suppose that widget is main widget. i.e. not child of another widget.
Hesam Qodsi
  • 1,569
  • 3
  • 25
  • 38
7
votes
2 answers

Post events without specifying target object in Qt

I need help to understand to use QEvents in QT, this is driving me crazy. I am writting an application using custom events, but as in QApplication::postEvent function, it's necesary to specify the target object. As I understand, it's possible to…
Hermandroid
  • 2,120
  • 4
  • 29
  • 35
7
votes
4 answers

Qt keyPressEvent not registering when W/A/S/D keys are pressed

I have an app (not related to any game where the W/A/S/D keys may have special meanings for navigation) where there is a QFrame. I overrode the keyPressEvent() to get the text being typed through keyboard while focus in on that QFrame. This is my…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
5
votes
2 answers

"QPainter::drawRects: Painter not active " error C++/QT

I'm a beginner at Qt and c++ and I wanted to see how to use a QPainter and events in Qt but I got stuck because of an error message during the execution, my original code: the main.cpp #include "customwidget.h" #include int main(int…
N.D.
  • 157
  • 1
  • 2
  • 10
4
votes
2 answers

Qt mouse move events not caught by an event filter

I can't seem to catch QEvent::MouseMove typed events in my eventFilter. Here's my event filter: bool MapWidget_c::eventFilter( QObject *obj, QEvent *ev ) { if( obj == graphicsGeoMap_mp || obj == graphicsScene_mp || obj ==…
Gerstmann
  • 5,368
  • 6
  • 37
  • 57
4
votes
1 answer

QT eventFilter with MouseButtonRelease on QListWidget is not detecting mouse press/release

It should be simple but somehow it's not working as it should. I'm trying to catch with eventFilter mouse button press or release on QListWidget. ListWidget was prepared under UI. I've installed eventFilter like this…
Pilot
  • 43
  • 1
  • 6
4
votes
2 answers

Managing keyboard events between Win32 app and QWinMigrate

I have integrated a Qt dialog into a traditional Win32 application, and am now a bit stumped on how to manage the keyboard events propagating from Qt->Win32. Is there any way test if Qt is 'handling' events (eg, input going to an editbox), and…
FrozenKiwi
  • 1,362
  • 13
  • 26
4
votes
2 answers

How to synthesize key press events?

I am able to get key value's from HAL through a call back function in Qt. Created event for that key by QKeyEvent *event = new QKeyEvent (QEvent::KeyPress, inputKey.keyValue, …
Lalatendu
  • 79
  • 1
  • 6
4
votes
1 answer

In Qt app how to capture "Cmd-Q" or "Quit" menu click

In my Qt app, I have a quit routine which gracefully cleans up everything before finally quitting, else there might be a crash somewhere. The app runs in the system tray, and there is a "Quit" menu defined for the system tray icon. On the quitAction…
Soumya Das
  • 1,635
  • 2
  • 19
  • 28
4
votes
1 answer

QWidget onMinimize() onMaximize() signals

I'm trying to find a signal to know when a qwidget is visible or not, I mean, when a QWidget is at the top of the desktop or when it's hide under some window. I also would like to know with a signal when a QWidget window is minimized and when it's…
Hermandroid
  • 2,120
  • 4
  • 29
  • 35
4
votes
3 answers

What's the QMetaCallEvent for and how to access its details?

I have an event filter and I noticed when I click to expand/collapse a tree branch I get QEvent::MetaCall. I was thinking about using this to roll my own expand/collapse code, but I don't know how to get any information, such as the index of the…
Rafe
  • 1,937
  • 22
  • 31
1
2 3 4 5 6 7 8