📄 qevent.cpp
字号:
#endif/*! \internal*/QPaintEvent::~QPaintEvent(){}/*! \fn const QRect &QPaintEvent::rect() const Returns the rectangle that needs to be updated. \sa region() QPainter::setClipRect()*//*! \fn const QRegion &QPaintEvent::region() const Returns the region that needs to be updated. \sa rect() QPainter::setClipRegion()*/QUpdateLaterEvent::QUpdateLaterEvent(const QRegion& paintRegion) : QEvent(UpdateLater), m_region(paintRegion){}QUpdateLaterEvent::~QUpdateLaterEvent(){}/*! \class QMoveEvent \brief The QMoveEvent class contains event parameters for move events. \ingroup events Move events are sent to widgets that have been moved to a new position relative to their parent. The event handler QWidget::moveEvent() receives move events. \sa QWidget::move(), QWidget::setGeometry()*//*! Constructs a move event with the new and old widget positions, \a pos and \a oldPos respectively.*/QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos) : QEvent(Move), p(pos), oldp(oldPos){}/*! \internal*/QMoveEvent::~QMoveEvent(){}/*! \fn const QPoint &QMoveEvent::pos() const Returns the new position of the widget. This excludes the window frame for top level widgets.*//*! \fn const QPoint &QMoveEvent::oldPos() const Returns the old position of the widget.*//*! \class QResizeEvent \brief The QResizeEvent class contains event parameters for resize events. \ingroup events Resize events are sent to widgets that have been resized. The event handler QWidget::resizeEvent() receives resize events. \sa QWidget::resize() QWidget::setGeometry()*//*! Constructs a resize event with the new and old widget sizes, \a size and \a oldSize respectively.*/QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize) : QEvent(Resize), s(size), olds(oldSize){}/*! \internal*/QResizeEvent::~QResizeEvent(){}/*! \fn const QSize &QResizeEvent::size() const Returns the new size of the widget. This is the same as QWidget::size().*//*! \fn const QSize &QResizeEvent::oldSize() const Returns the old size of the widget.*//*! \class QCloseEvent \brief The QCloseEvent class contains parameters that describe a close event. \ingroup events Close events are sent to widgets that the user wants to close, usually by choosing "Close" from the window menu, or by clicking the \gui{X} title bar button. They are also sent when you call QWidget::close() to close a widget programmatically. Close events contain a flag that indicates whether the receiver wants the widget to be closed or not. When a widget accepts the close event, it is hidden (and destroyed if it was created with the Qt::WA_DeleteOnClose flag). If it refuses to accept the close event nothing happens. (Under X11 it is possible that the window manager will forcibly close the window; but at the time of writing we are not aware of any window manager that does this.) The event handler QWidget::closeEvent() receives close events. The default implementation of this event handler accepts the close event. If you do not want your widget to be hidden, or want some special handing, you should reimplement the event handler and ignore() the event. The \l{mainwindows/application#close event handler}{closeEvent() in the Application example} shows a close event handler that asks whether to save a document before closing. If you want the widget to be deleted when it is closed, create it with the Qt::WA_DeleteOnClose flag. This is very useful for independent top-level windows in a multi-window application. \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()} signal when they are deleted. If the last top-level window is closed, the QApplication::lastWindowClosed() signal is emitted. The isAccepted() function returns true if the event's receiver has agreed to close the widget; call accept() to agree to close the widget and call ignore() if the receiver of this event does not want the widget to be closed. \sa QWidget::close(), QWidget::hide(), QObject::destroyed(), QCoreApplication::exec(), QCoreApplication::quit(), QApplication::lastWindowClosed()*//*! Constructs a close event object. \sa accept()*/QCloseEvent::QCloseEvent() : QEvent(Close){}/*! \internal*/QCloseEvent::~QCloseEvent(){}/*! \class QIconDragEvent \brief The QIconDragEvent class indicates that a main icon drag has begun. \ingroup events Icon drag events are sent to widgets when the main icon of a window has been dragged away. On Mac OS X, this happens when the proxy icon of a window is dragged off the title bar. It is normal to begin using drag and drop in response to this event. \sa {Drag and Drop}, QMimeData, QDrag*//*! Constructs an icon drag event object with the accept flag set to false. \sa accept()*/QIconDragEvent::QIconDragEvent() : QEvent(IconDrag){ ignore(); }/*! \internal */QIconDragEvent::~QIconDragEvent(){}/*! \class QContextMenuEvent \brief The QContextMenuEvent class contains parameters that describe a context menu event. \ingroup events Context menu events are sent to widgets when a user performs an action associated with opening a context menu. The actions required to open context menus vary between platforms; for example, on Windows, pressing the menu button or clicking the right mouse button will cause this event to be sent. When this event occurs it is customary to show a QMenu with a context menu, if this is relevant to the context. Context menu events contain a special accept flag that indicates whether the receiver accepted the event. If the event handler does not accept the event then, if possible, whatever triggered the event will be handled as a regular input event.*//*! Constructs a context menu event object with the accept parameter flag set to false. The \a reason parameter must be QContextMenuEvent::Mouse or QContextMenuEvent::Keyboard. The \a pos parameter specifies the mouse position relative to the receiving widget. \a globalPos is the mouse position in absolute coordinates.*/QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos) : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason){}#ifdef QT3_SUPPORT/*! Constructs a context menu event with the given \a reason for the position specified by \a pos in widget coordinates and \a globalPos in global screen coordinates. \a dummy is ignored.*/QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos, int /* dummy */) : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason){}#endif/*! \internal */QContextMenuEvent::~QContextMenuEvent(){}/*! Constructs a context menu event object with the accept parameter flag set to false. The \a reason parameter must be QContextMenuEvent::Mouse or QContextMenuEvent::Keyboard. The \a pos parameter specifies the mouse position relative to the receiving widget. The globalPos() is initialized to QCursor::pos(), which may not be appropriate. Use the other constructor to specify the global position explicitly.*/QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos) : QInputEvent(ContextMenu), p(pos), reas(reason){ gp = QCursor::pos();}#ifdef QT3_SUPPORT/*! Constructs a context menu event with the given \a reason for the position specified by \a pos in widget coordinates. \a dummy is ignored.*/QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, int /* dummy */) : QInputEvent(ContextMenu), p(pos), reas(reason){ gp = QCursor::pos();}Qt::ButtonState QContextMenuEvent::state() const{ return Qt::ButtonState(int(QApplication::keyboardModifiers())|QApplication::mouseButtons());}#endif/*! \fn const QPoint &QContextMenuEvent::pos() const Returns the position of the mouse pointer relative to the widget that received the event. \sa x(), y(), globalPos()*//*! \fn int QContextMenuEvent::x() const Returns the x position of the mouse pointer, relative to the widget that received the event. \sa y(), pos()*//*! \fn int QContextMenuEvent::y() const Returns the y position of the mouse pointer, relative to the widget that received the event. \sa x(), pos()*//*! \fn const QPoint &QContextMenuEvent::globalPos() const Returns the global position of the mouse pointer at the time of the event. \sa x(), y(), pos()*//*! \fn int QContextMenuEvent::globalX() const Returns the global x position of the mouse pointer at the time of the event. \sa globalY(), globalPos()*//*! \fn int QContextMenuEvent::globalY() const Returns the global y position of the mouse pointer at the time of the event. \sa globalX(), globalPos()*//*! \fn Qt::ButtonState QContextMenuEvent::state() const Returns the button state (a combination of mouse buttons and keyboard modifiers) immediately before the event was generated. The returned value is a selection of the following values, combined with the OR operator: Qt::LeftButton, Qt::RightButton, Qt::MidButton, Qt::ShiftButton, Qt::ControlButton, and Qt::AltButton.*//*! \enum QContextMenuEvent::Reason This enum describes the reason why the event was sent. \value Mouse The mouse caused the event to be sent. Normally this means the right mouse button was clicked, but this is platform dependent. \value Keyboard The keyboard caused this event to be sent. On Windows, this means the menu button was pressed. \value Other The event was sent by some other means (i.e. not by the mouse or keyboard).*//*! \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const Returns the reason for this context event.*//*! \class QInputMethodEvent \brief The QInputMethodEvent class provides parameters for input method events. \ingroup events Input method events are sent to widgets when an input method is used to enter text into a widget. Input methods are widely used to enter text for languages with non-Latin alphabets. The events are of interest to authors of keyboard entry widgets who want to be able to correctly handle languages with complex character input. Text input in such languages is usually a three step process: \list 1 \o \bold{Starting to Compose} When the user presses the first key on a keyboard, an input context is created. This input context will contain a string of the typed characters. \o \bold{Composing} With every new key pressed, the input method will try to create a matching string for the text typed so far called preedit string. While the input context is active, the user can only move the cursor inside the string belonging to this input context. \o \bold{Completing} At some point, the user will activate a user interface component (perhaps using a particular key) where they can choose from a number of strings matching the text they have typed so far. The user can either confirm their choice cancel the input; in either case the input context will be closed. \endlist QInputMethodEvent models these three stages, and transfers the information needed to correctly render the intermediate result. A QInputMethodEvent has two main parameters: preeditString() and commitString(). The preeditString() parameter gives the currently active preedit string. The commitString() parameter gives a text
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -