📄 qevent.cpp
字号:
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initial key press. Note that if the event is a multiple-key compressed event that is partly due to auto-repeat, this function could return either true or false indeterminately.*//*! \fn int QKeyEvent::count() const Returns the number of keys involved in this event. If text() is not empty, this is simply the length of the string. \sa Qt::WA_KeyCompression*/#ifdef QT3_SUPPORT/*! \fn QKeyEvent::QKeyEvent(Type type, int key, int ascii, int modifiers, const QString &text, bool autorep, ushort count) Use one of the other constructors instead.*//*! \fn int QKeyEvent::ascii() const Use text() instead.*//*! \fn Qt::ButtonState QKeyEvent::state() const Use QInputEvent::modifiers() instead.*//*! \fn Qt::ButtonState QKeyEvent::stateAfter() const Use modifiers() instead.*/#endif/*! \class QFocusEvent \brief The QFocusEvent class contains event parameters for widget focus events. \ingroup events Focus events are sent to widgets when the keyboard input focus changes. Focus events occur due to mouse actions, key presses (such as \gui{Tab} or \gui{Backtab}), the window system, popup menus, keyboard shortcuts, or other application-specific reasons. The reason for a particular focus event is returned by reason() in the appropriate event handler. The event handlers QWidget::focusInEvent() and QWidget::focusOutEvent() receive focus events. \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}*//*! Constructs a focus event object. The \a type parameter must be either QEvent::FocusIn or QEvent::FocusOut. The \a reason describes the cause of the change in focus.*/QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason) : QEvent(type), m_reason(reason){}/*! \internal*/QFocusEvent::~QFocusEvent(){}// ### Qt 5: remove/*! \internal */Qt::FocusReason QFocusEvent::reason(){ return m_reason;}/*! Returns the reason for this focus event. */Qt::FocusReason QFocusEvent::reason() const{ return m_reason;}/*! \fn bool QFocusEvent::gotFocus() const Returns true if type() is QEvent::FocusIn; otherwise returns false.*//*! \fn bool QFocusEvent::lostFocus() const Returns true if type() is QEvent::FocusOut; otherwise returns false.*/#ifdef QT3_SUPPORT/*! \enum QFocusEvent::Reason \compat Use Qt::FocusReason instead. \value Mouse Same as Qt::MouseFocusReason. \value Tab Same as Qt::TabFocusReason. \value Backtab Same as Qt::BacktabFocusReason. \value MenuBar Same as Qt::MenuBarFocusReason. \value ActiveWindow Same as Qt::ActiveWindowFocusReason \value Other Same as Qt::OtherFocusReason \value Popup Same as Qt::PopupFocusReason \value Shortcut Same as Qt::ShortcutFocusReason*/#endif/*! \class QPaintEvent \brief The QPaintEvent class contains event parameters for paint events. \ingroup events Paint events are sent to widgets that need to update themselves, for instance when part of a widget is exposed because a covering widget was moved. The event contains a region() that needs to be updated, and a rect() that is the bounding rectangle of that region. Both are provided because many widgets can't make much use of region(), and rect() can be much faster than region().boundingRect(). Painting is clipped to region() during the processing of a paint event. \sa QPainter, QWidget::update(), QWidget::repaint(), QWidget::paintEvent()*//*! \fn bool QPaintEvent::erased() const \compat Returns true if the paint event region (or rectangle) has been erased with the widget's background; otherwise returns false. Qt 4 \e always erases regions that require painting. The exception to this rule is if the widget sets the Qt::WA_OpaquePaintEvent or Qt::WA_NoSystemBackground attributes. If either one of those attributes is set \e and the window system does not make use of subwidget alpha composition (currently X11 and Windows, but this may change), then the region is not erased.*//*! \fn void QPaintEvent::setErased(bool b) { m_erased = b; } \internal*//*! Constructs a paint event object with the region that needs to be updated. The region is specified by \a paintRegion.*/QPaintEvent::QPaintEvent(const QRegion& paintRegion) : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false){}/*! Constructs a paint event object with the rectangle that needs to be updated. The region is specified by \a paintRect.*/QPaintEvent::QPaintEvent(const QRect &paintRect) : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false){}#ifdef QT3_SUPPORT /*! Constructs a paint event object with both a \a paintRegion and a \a paintRect, both of which represent the area of the widget that needs to be updated.*/QPaintEvent::QPaintEvent(const QRegion &paintRegion, const QRect &paintRect) : QEvent(Paint), m_rect(paintRect), m_region(paintRegion), m_erased(false){}#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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -