qevent

Is there a cleaner way to register Qt custom events?

谁说胖子不能爱 提交于 2019-12-13 11:42:25
问题 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:

How to register for ACTION_VIEW Intent on Android? Why doesn't my QApplication receive QEvent::FileOpen events?

和自甴很熟 提交于 2019-12-13 05:23:43
问题 I am trying to register a QtQuick Android application to open a certain class of files and handle them. From what I gather, when a file is opened with a QApplication it results in a QEvent::FileOpen being fired. The strongest (if inconclusive) evidence for this I have is this commit found in a production system, plus a number of blog posts and Google results. So, I first create a new empty QtQuick project. I then write an EventFilter, like this: #include <QtGui> #include <QApplication>

QTableView doesn't send expected FocusIn / FocusOut events to eventFilter

左心房为你撑大大i 提交于 2019-12-11 04:25:24
问题 I have a QTableWidget with floats or complex entries that need a lot of horizontal space. Displaying the values with reduced number of digits via string formatting works fine, but obviously I loose precision when editing and storing entries in the table. I have found a solution for QLineEdit widgets by using an eventFilter: A FocusIn event copies the stored value with full precision to the QLineEdit textfield, a FocusOut event or a Return_Key stores the changed value and overwrites the text

Learn about occurred events from other class

烈酒焚心 提交于 2019-12-11 04:13:10
问题 I have two classes: typedef std::shared_ptr<AdaptedWidget> window_ptr; class WindowManager { public: ... private: std::stack<window_ptr> m_windowsStack; } and class AdaptedWidget: public QWidget { Q_OBJECT public: AdaptedWidget(AdaptedWidget *parent = 0); bool event(QEvent *event); }; bool AdaptedWidget::event(QEvent *event) { if (event->type() == QEvent::NonClientAreaMouseButtonPress || event->type() == QEvent::MouseButtonPress) { qDebug() << "mainwindwo press"; } return QWidget::event(event

Qt. Declare custom QEvent type ONCE

拜拜、爱过 提交于 2019-12-10 22:37:18
问题 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 different integer value. If make a break point on that code above, debugger stops 9 times. Please help how to declare custom QEvent type ONCE 回答1: I'm not 100% sure I'm understanding your question, but it sounds like you need to separate the declaration and the

create & post the customized Qevent

一世执手 提交于 2019-12-06 10:13:17
问题 I have to create an 2 custom events. I followed this link & made my code :-- Is there a cleaner way to register Qt custom events? Is it the right way to create & post & pass some data(Qstring) to the customized event ? =========================================================== Edit code as per Kuba Ober sugession :--- Mainwindow.h :-- UpdateEvent *myUpdateEvent ; ClearEvent *myClearEvent ; Mainwindow.c :--- MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)

How to detect that my application lost focus in Qt?

旧时模样 提交于 2019-12-05 23:50:14
问题 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 application by Alt+Tab . I figured out that I probably need to catch another event, but somehow I can't find the proper one. Can you suggest one? 回答1: The event you are looking for is QEvent::ApplicationDeactivate : "The application has been

Qt mouse move events not caught by an event filter

百般思念 提交于 2019-12-05 17:21:16
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 == graphicsView_mp ) { if( ev->type() == QEvent::MouseMove ) { QMouseEvent *mouseEvent = static_cast< QMouseEvent* >( ev ); mouseMoveEvent( mouseEvent ); return true; } else { return false; } } else { // pass the event on to the parent class return QWidget::eventFilter( obj, ev ); } } I install the filters like this: graphicsGeoMap_mp->installEventFilter( this ); /

create & post the customized Qevent

一个人想着一个人 提交于 2019-12-04 17:14:57
I have to create an 2 custom events. I followed this link & made my code :-- Is there a cleaner way to register Qt custom events? Is it the right way to create & post & pass some data(Qstring) to the customized event ? =========================================================== Edit code as per Kuba Ober sugession :--- Mainwindow.h :-- UpdateEvent *myUpdateEvent ; ClearEvent *myClearEvent ; Mainwindow.c :--- MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); i =0; myUpdateEvent = new UpdateEvent("hello"); myClearEvent = new ClearEvent(

How to detect that my application lost focus in Qt?

陌路散爱 提交于 2019-12-04 06:19:32
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 application by Alt+Tab . I figured out that I probably need to catch another event, but somehow I can't find the proper one. Can you suggest one? The event you are looking for is QEvent::ApplicationDeactivate : "The application has been suspended, and is unavailable to the user". You can install an event filter on your QApplication instance to catch