[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include "qevent.h"
|
---|
| 43 | #include "qcursor.h"
|
---|
| 44 | #include "qapplication.h"
|
---|
| 45 | #include "private/qapplication_p.h"
|
---|
| 46 | #include "private/qkeysequence_p.h"
|
---|
| 47 | #include "qwidget.h"
|
---|
[561] | 48 | #include "qgraphicsview.h"
|
---|
[2] | 49 | #include "qdebug.h"
|
---|
| 50 | #include "qmime.h"
|
---|
| 51 | #include "qdnd_p.h"
|
---|
| 52 | #include "qevent_p.h"
|
---|
[561] | 53 | #include "qgesture.h"
|
---|
| 54 | #include "qgesture_p.h"
|
---|
[2] | 55 |
|
---|
| 56 | QT_BEGIN_NAMESPACE
|
---|
| 57 |
|
---|
| 58 | /*!
|
---|
| 59 | \class QInputEvent
|
---|
| 60 | \ingroup events
|
---|
| 61 |
|
---|
| 62 | \brief The QInputEvent class is the base class for events that
|
---|
| 63 | describe user input.
|
---|
| 64 | */
|
---|
| 65 |
|
---|
| 66 | /*!
|
---|
| 67 | \internal
|
---|
| 68 | */
|
---|
| 69 | QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
|
---|
| 70 | : QEvent(type), modState(modifiers)
|
---|
| 71 | {}
|
---|
| 72 |
|
---|
| 73 | /*!
|
---|
| 74 | \internal
|
---|
| 75 | */
|
---|
| 76 | QInputEvent::~QInputEvent()
|
---|
| 77 | {
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | /*!
|
---|
| 81 | \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
|
---|
| 82 |
|
---|
| 83 | Returns the keyboard modifier flags that existed immediately
|
---|
| 84 | before the event occurred.
|
---|
| 85 |
|
---|
| 86 | \sa QApplication::keyboardModifiers()
|
---|
| 87 | */
|
---|
| 88 |
|
---|
[561] | 89 | /*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
|
---|
| 90 |
|
---|
| 91 | \internal
|
---|
| 92 |
|
---|
| 93 | Sets the keyboard modifiers flags for this event.
|
---|
| 94 | */
|
---|
| 95 |
|
---|
[2] | 96 | /*!
|
---|
| 97 | \class QMouseEvent
|
---|
| 98 | \ingroup events
|
---|
| 99 |
|
---|
| 100 | \brief The QMouseEvent class contains parameters that describe a mouse event.
|
---|
| 101 |
|
---|
| 102 | Mouse events occur when a mouse button is pressed or released
|
---|
| 103 | inside a widget, or when the mouse cursor is moved.
|
---|
| 104 |
|
---|
| 105 | Mouse move events will occur only when a mouse button is pressed
|
---|
| 106 | down, unless mouse tracking has been enabled with
|
---|
| 107 | QWidget::setMouseTracking().
|
---|
| 108 |
|
---|
| 109 | Qt automatically grabs the mouse when a mouse button is pressed
|
---|
| 110 | inside a widget; the widget will continue to receive mouse events
|
---|
| 111 | until the last mouse button is released.
|
---|
| 112 |
|
---|
| 113 | A mouse event contains a special accept flag that indicates
|
---|
| 114 | whether the receiver wants the event. You should call ignore() if
|
---|
| 115 | the mouse event is not handled by your widget. A mouse event is
|
---|
| 116 | propagated up the parent widget chain until a widget accepts it
|
---|
| 117 | with accept(), or an event filter consumes it.
|
---|
| 118 |
|
---|
[561] | 119 | \note If a mouse event is propagated to a \l{QWidget}{widget} for
|
---|
| 120 | which Qt::WA_NoMousePropagation has been set, that mouse event
|
---|
| 121 | will not be propagated further up the parent widget chain.
|
---|
| 122 |
|
---|
[2] | 123 | The state of the keyboard modifier keys can be found by calling the
|
---|
[561] | 124 | \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
|
---|
[2] | 125 | QInputEvent.
|
---|
| 126 |
|
---|
| 127 | The functions pos(), x(), and y() give the cursor position
|
---|
| 128 | relative to the widget that receives the mouse event. If you
|
---|
| 129 | move the widget as a result of the mouse event, use the global
|
---|
| 130 | position returned by globalPos() to avoid a shaking motion.
|
---|
| 131 |
|
---|
| 132 | The QWidget::setEnabled() function can be used to enable or
|
---|
| 133 | disable mouse and keyboard events for a widget.
|
---|
| 134 |
|
---|
| 135 | Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
|
---|
| 136 | QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
|
---|
| 137 | and QWidget::mouseMoveEvent() to receive mouse events in your own
|
---|
| 138 | widgets.
|
---|
| 139 |
|
---|
| 140 | \sa QWidget::setMouseTracking() QWidget::grabMouse()
|
---|
| 141 | QCursor::pos()
|
---|
| 142 | */
|
---|
| 143 |
|
---|
| 144 | /*!
|
---|
| 145 | Constructs a mouse event object.
|
---|
| 146 |
|
---|
| 147 | The \a type parameter must be one of QEvent::MouseButtonPress,
|
---|
| 148 | QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
|
---|
| 149 | or QEvent::MouseMove.
|
---|
| 150 |
|
---|
| 151 | The \a position is the mouse cursor's position relative to the
|
---|
| 152 | receiving widget.
|
---|
| 153 | The \a button that caused the event is given as a value from
|
---|
| 154 | the Qt::MouseButton enum. If the event \a type is
|
---|
| 155 | \l MouseMove, the appropriate button for this event is Qt::NoButton.
|
---|
| 156 | The mouse and keyboard states at the time of the event are specified by
|
---|
| 157 | \a buttons and \a modifiers.
|
---|
| 158 |
|
---|
| 159 | The globalPos() is initialized to QCursor::pos(), which may not
|
---|
| 160 | be appropriate. Use the other constructor to specify the global
|
---|
| 161 | position explicitly.
|
---|
| 162 | */
|
---|
| 163 |
|
---|
| 164 | QMouseEvent::QMouseEvent(Type type, const QPoint &position, Qt::MouseButton button,
|
---|
| 165 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
|
---|
| 166 | : QInputEvent(type, modifiers), p(position), b(button), mouseState(buttons)
|
---|
| 167 | {
|
---|
| 168 | g = QCursor::pos();
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | /*!
|
---|
| 172 | \internal
|
---|
| 173 | */
|
---|
| 174 | QMouseEvent::~QMouseEvent()
|
---|
| 175 | {
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | #ifdef QT3_SUPPORT
|
---|
| 179 | /*!
|
---|
| 180 | Use QMouseEvent(\a type, \a pos, \a button, \c buttons, \c
|
---|
| 181 | modifiers) instead, where \c buttons is \a state &
|
---|
| 182 | Qt::MouseButtonMask and \c modifiers is \a state &
|
---|
| 183 | Qt::KeyButtonMask.
|
---|
| 184 | */
|
---|
| 185 | QMouseEvent::QMouseEvent(Type type, const QPoint &pos, Qt::ButtonState button, int state)
|
---|
| 186 | : QInputEvent(type), p(pos), b((Qt::MouseButton)button)
|
---|
| 187 | {
|
---|
| 188 | g = QCursor::pos();
|
---|
| 189 | mouseState = Qt::MouseButtons((state ^ b) & Qt::MouseButtonMask);
|
---|
| 190 | modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | /*!
|
---|
| 194 | Use QMouseEvent(\a type, \a pos, \a globalPos, \a button,
|
---|
| 195 | \c buttons, \c modifiers) instead, where
|
---|
| 196 | \c buttons is \a state & Qt::MouseButtonMask and
|
---|
| 197 | \c modifiers is \a state & Qt::KeyButtonMask.
|
---|
| 198 | */
|
---|
| 199 | QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
|
---|
| 200 | Qt::ButtonState button, int state)
|
---|
| 201 | : QInputEvent(type), p(pos), g(globalPos), b((Qt::MouseButton)button)
|
---|
| 202 | {
|
---|
| 203 | mouseState = Qt::MouseButtons((state ^ b) & Qt::MouseButtonMask);
|
---|
| 204 | modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);
|
---|
| 205 | }
|
---|
| 206 | #endif
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | /*!
|
---|
| 210 | Constructs a mouse event object.
|
---|
| 211 |
|
---|
| 212 | The \a type parameter must be QEvent::MouseButtonPress,
|
---|
| 213 | QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
|
---|
| 214 | or QEvent::MouseMove.
|
---|
| 215 |
|
---|
| 216 | The \a pos is the mouse cursor's position relative to the
|
---|
| 217 | receiving widget. The cursor's position in global coordinates is
|
---|
| 218 | specified by \a globalPos. The \a button that caused the event is
|
---|
| 219 | given as a value from the \l Qt::MouseButton enum. If the event \a
|
---|
| 220 | type is \l MouseMove, the appropriate button for this event is
|
---|
| 221 | Qt::NoButton. \a buttons is the state of all buttons at the
|
---|
| 222 | time of the event, \a modifiers the state of all keyboard
|
---|
| 223 | modifiers.
|
---|
| 224 |
|
---|
| 225 | */
|
---|
| 226 | QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
|
---|
| 227 | Qt::MouseButton button, Qt::MouseButtons buttons,
|
---|
| 228 | Qt::KeyboardModifiers modifiers)
|
---|
| 229 | : QInputEvent(type, modifiers), p(pos), g(globalPos), b(button), mouseState(buttons)
|
---|
| 230 | {}
|
---|
| 231 |
|
---|
| 232 | /*!
|
---|
| 233 | \internal
|
---|
| 234 | */
|
---|
| 235 | QMouseEvent *QMouseEvent::createExtendedMouseEvent(Type type, const QPointF &pos,
|
---|
| 236 | const QPoint &globalPos, Qt::MouseButton button,
|
---|
| 237 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
|
---|
| 238 | {
|
---|
| 239 | return new QMouseEventEx(type, pos, globalPos, button, buttons, modifiers);
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | /*!
|
---|
| 243 | \fn bool QMouseEvent::hasExtendedInfo() const
|
---|
| 244 | \internal
|
---|
| 245 | */
|
---|
| 246 |
|
---|
| 247 | /*!
|
---|
| 248 | \since 4.4
|
---|
| 249 |
|
---|
| 250 | Returns the position of the mouse cursor as a QPointF, relative to the
|
---|
| 251 | widget that received the event.
|
---|
| 252 |
|
---|
| 253 | If you move the widget as a result of the mouse event, use the
|
---|
| 254 | global position returned by globalPos() to avoid a shaking
|
---|
| 255 | motion.
|
---|
| 256 |
|
---|
| 257 | \sa x() y() pos() globalPos()
|
---|
| 258 | */
|
---|
| 259 | QPointF QMouseEvent::posF() const
|
---|
| 260 | {
|
---|
| 261 | return hasExtendedInfo() ? reinterpret_cast<const QMouseEventEx *>(this)->posF : QPointF(pos());
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | /*!
|
---|
| 265 | \internal
|
---|
| 266 | */
|
---|
| 267 | QMouseEventEx::QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
|
---|
| 268 | Qt::MouseButton button, Qt::MouseButtons buttons,
|
---|
| 269 | Qt::KeyboardModifiers modifiers)
|
---|
| 270 | : QMouseEvent(type, pos.toPoint(), globalPos, button, buttons, modifiers), posF(pos)
|
---|
| 271 | {
|
---|
| 272 | d = reinterpret_cast<QEventPrivate *>(this);
|
---|
| 273 | }
|
---|
| 274 |
|
---|
| 275 | /*!
|
---|
| 276 | \internal
|
---|
| 277 | */
|
---|
| 278 | QMouseEventEx::~QMouseEventEx()
|
---|
| 279 | {
|
---|
| 280 | }
|
---|
| 281 |
|
---|
| 282 | /*!
|
---|
| 283 | \fn const QPoint &QMouseEvent::pos() const
|
---|
| 284 |
|
---|
| 285 | Returns the position of the mouse cursor, relative to the widget
|
---|
| 286 | that received the event.
|
---|
| 287 |
|
---|
| 288 | If you move the widget as a result of the mouse event, use the
|
---|
| 289 | global position returned by globalPos() to avoid a shaking
|
---|
| 290 | motion.
|
---|
| 291 |
|
---|
| 292 | \sa x() y() globalPos()
|
---|
| 293 | */
|
---|
| 294 |
|
---|
| 295 | /*!
|
---|
| 296 | \fn const QPoint &QMouseEvent::globalPos() const
|
---|
| 297 |
|
---|
| 298 | Returns the global position of the mouse cursor \e{at the time
|
---|
| 299 | of the event}. This is important on asynchronous window systems
|
---|
| 300 | like X11. Whenever you move your widgets around in response to
|
---|
| 301 | mouse events, globalPos() may differ a lot from the current
|
---|
| 302 | pointer position QCursor::pos(), and from
|
---|
| 303 | QWidget::mapToGlobal(pos()).
|
---|
| 304 |
|
---|
| 305 | \sa globalX() globalY()
|
---|
| 306 | */
|
---|
| 307 |
|
---|
| 308 | /*!
|
---|
| 309 | \fn int QMouseEvent::x() const
|
---|
| 310 |
|
---|
| 311 | Returns the x position of the mouse cursor, relative to the
|
---|
| 312 | widget that received the event.
|
---|
| 313 |
|
---|
| 314 | \sa y() pos()
|
---|
| 315 | */
|
---|
| 316 |
|
---|
| 317 | /*!
|
---|
| 318 | \fn int QMouseEvent::y() const
|
---|
| 319 |
|
---|
| 320 | Returns the y position of the mouse cursor, relative to the
|
---|
| 321 | widget that received the event.
|
---|
| 322 |
|
---|
| 323 | \sa x() pos()
|
---|
| 324 | */
|
---|
| 325 |
|
---|
| 326 | /*!
|
---|
| 327 | \fn int QMouseEvent::globalX() const
|
---|
| 328 |
|
---|
| 329 | Returns the global x position of the mouse cursor at the time of
|
---|
| 330 | the event.
|
---|
| 331 |
|
---|
| 332 | \sa globalY() globalPos()
|
---|
| 333 | */
|
---|
| 334 |
|
---|
| 335 | /*!
|
---|
| 336 | \fn int QMouseEvent::globalY() const
|
---|
| 337 |
|
---|
| 338 | Returns the global y position of the mouse cursor at the time of
|
---|
| 339 | the event.
|
---|
| 340 |
|
---|
| 341 | \sa globalX() globalPos()
|
---|
| 342 | */
|
---|
| 343 |
|
---|
| 344 | /*!
|
---|
| 345 | \fn Qt::MouseButton QMouseEvent::button() const
|
---|
| 346 |
|
---|
| 347 | Returns the button that caused the event.
|
---|
| 348 |
|
---|
| 349 | Note that the returned value is always Qt::NoButton for mouse
|
---|
| 350 | move events.
|
---|
| 351 |
|
---|
| 352 | \sa buttons() Qt::MouseButton
|
---|
| 353 | */
|
---|
| 354 |
|
---|
| 355 | /*!
|
---|
| 356 | \fn Qt::MouseButton QMouseEvent::buttons() const
|
---|
| 357 |
|
---|
| 358 | Returns the button state when the event was generated. The button
|
---|
| 359 | state is a combination of Qt::LeftButton, Qt::RightButton,
|
---|
| 360 | Qt::MidButton using the OR operator. For mouse move events,
|
---|
| 361 | this is all buttons that are pressed down. For mouse press and
|
---|
| 362 | double click events this includes the button that caused the
|
---|
| 363 | event. For mouse release events this excludes the button that
|
---|
| 364 | caused the event.
|
---|
| 365 |
|
---|
| 366 | \sa button() Qt::MouseButton
|
---|
| 367 | */
|
---|
| 368 |
|
---|
| 369 |
|
---|
| 370 | /*!
|
---|
| 371 | \fn Qt::ButtonState QMouseEvent::state() const
|
---|
| 372 |
|
---|
| 373 | Returns the button state immediately before the event was
|
---|
| 374 | generated. The button state is a combination of mouse buttons
|
---|
| 375 | (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
|
---|
| 376 |
|
---|
| 377 | Use buttons() and/or modifiers() instead. Be aware that buttons()
|
---|
| 378 | return the state immediately \e after the event was generated.
|
---|
| 379 | */
|
---|
| 380 |
|
---|
| 381 | /*!
|
---|
| 382 | \fn Qt::ButtonState QMouseEvent::stateAfter() const
|
---|
| 383 |
|
---|
| 384 | Returns the button state immediately after the event was
|
---|
| 385 | generated. The button state is a combination of mouse buttons
|
---|
| 386 | (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
|
---|
| 387 |
|
---|
| 388 | Use buttons() and/or modifiers() instead.
|
---|
| 389 | */
|
---|
| 390 |
|
---|
| 391 | /*!
|
---|
| 392 | \class QHoverEvent
|
---|
| 393 | \ingroup events
|
---|
| 394 |
|
---|
| 395 | \brief The QHoverEvent class contains parameters that describe a mouse event.
|
---|
| 396 |
|
---|
| 397 | Mouse events occur when a mouse cursor is moved into, out of, or within a
|
---|
| 398 | widget, and if the widget has the Qt::WA_Hover attribute.
|
---|
| 399 |
|
---|
| 400 | The function pos() gives the current cursor position, while oldPos() gives
|
---|
| 401 | the old mouse position.
|
---|
[561] | 402 |
|
---|
| 403 | There are a few similarities between the events QEvent::HoverEnter
|
---|
| 404 | and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
|
---|
| 405 | However, they are slightly different because we do an update() in the event
|
---|
| 406 | handler of HoverEnter and HoverLeave.
|
---|
| 407 |
|
---|
| 408 | QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
|
---|
| 409 | consider a top-level window A containing a child B which in turn contains a
|
---|
| 410 | child C (all with mouse tracking enabled):
|
---|
| 411 |
|
---|
| 412 | \image hoverevents.png
|
---|
| 413 |
|
---|
| 414 | Now, if you move the cursor from the top to the bottom in the middle of A,
|
---|
| 415 | you will get the following QEvent::MouseMove events:
|
---|
| 416 |
|
---|
| 417 | \list 1
|
---|
| 418 | \o A::MouseMove
|
---|
| 419 | \o B::MouseMove
|
---|
| 420 | \o C::MouseMove
|
---|
| 421 | \endlist
|
---|
| 422 |
|
---|
| 423 | You will get the same events for QEvent::HoverMove, except that the event
|
---|
| 424 | always propagates to the top-level regardless whether the event is accepted
|
---|
| 425 | or not. It will only stop propagating with the Qt::WA_NoMousePropagation
|
---|
| 426 | attribute.
|
---|
| 427 |
|
---|
| 428 | In this case the events will occur in the following way:
|
---|
| 429 |
|
---|
| 430 | \list 1
|
---|
| 431 | \o A::HoverMove
|
---|
| 432 | \o A::HoverMove, B::HoverMove
|
---|
| 433 | \o A::HoverMove, B::HoverMove, C::HoverMove
|
---|
| 434 | \endlist
|
---|
| 435 |
|
---|
[2] | 436 | */
|
---|
| 437 |
|
---|
| 438 | /*!
|
---|
| 439 | \fn const QPoint &QHoverEvent::pos() const
|
---|
| 440 |
|
---|
| 441 | Returns the position of the mouse cursor, relative to the widget
|
---|
| 442 | that received the event.
|
---|
| 443 |
|
---|
| 444 | On QEvent::HoverLeave events, this position will always be
|
---|
| 445 | QPoint(-1, -1).
|
---|
| 446 |
|
---|
| 447 | \sa oldPos()
|
---|
| 448 | */
|
---|
| 449 |
|
---|
| 450 | /*!
|
---|
| 451 | \fn const QPoint &QHoverEvent::oldPos() const
|
---|
| 452 |
|
---|
| 453 | Returns the previous position of the mouse cursor, relative to the widget
|
---|
| 454 | that received the event. If there is no previous position, oldPos() will
|
---|
| 455 | return the same position as pos().
|
---|
| 456 |
|
---|
| 457 | On QEvent::HoverEnter events, this position will always be
|
---|
| 458 | QPoint(-1, -1).
|
---|
| 459 |
|
---|
| 460 | \sa pos()
|
---|
| 461 | */
|
---|
| 462 |
|
---|
| 463 | /*!
|
---|
| 464 | Constructs a hover event object.
|
---|
| 465 |
|
---|
| 466 | The \a type parameter must be QEvent::HoverEnter,
|
---|
| 467 | QEvent::HoverLeave, or QEvent::HoverMove.
|
---|
| 468 |
|
---|
| 469 | The \a pos is the current mouse cursor's position relative to the
|
---|
| 470 | receiving widget, while \a oldPos is the previous mouse cursor's
|
---|
| 471 | position relative to the receiving widget.
|
---|
| 472 | */
|
---|
| 473 | QHoverEvent::QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos)
|
---|
| 474 | : QEvent(type), p(pos), op(oldPos)
|
---|
| 475 | {
|
---|
| 476 | }
|
---|
| 477 |
|
---|
| 478 | /*!
|
---|
| 479 | \internal
|
---|
| 480 | */
|
---|
| 481 | QHoverEvent::~QHoverEvent()
|
---|
| 482 | {
|
---|
| 483 | }
|
---|
| 484 |
|
---|
| 485 |
|
---|
| 486 | /*!
|
---|
| 487 | \class QWheelEvent
|
---|
| 488 | \brief The QWheelEvent class contains parameters that describe a wheel event.
|
---|
| 489 |
|
---|
| 490 | \ingroup events
|
---|
| 491 |
|
---|
| 492 | Wheel events are sent to the widget under the mouse cursor, but
|
---|
| 493 | if that widget does not handle the event they are sent to the
|
---|
| 494 | focus widget. The rotation distance is provided by delta().
|
---|
| 495 | The functions pos() and globalPos() return the mouse cursor's
|
---|
| 496 | location at the time of the event.
|
---|
| 497 |
|
---|
| 498 | A wheel event contains a special accept flag that indicates
|
---|
| 499 | whether the receiver wants the event. You should call ignore() if
|
---|
| 500 | you do not handle the wheel event; this ensures that it will be
|
---|
| 501 | sent to the parent widget.
|
---|
| 502 |
|
---|
| 503 | The QWidget::setEnabled() function can be used to enable or
|
---|
| 504 | disable mouse and keyboard events for a widget.
|
---|
| 505 |
|
---|
| 506 | The event handler QWidget::wheelEvent() receives wheel events.
|
---|
| 507 |
|
---|
| 508 | \sa QMouseEvent QWidget::grabMouse()
|
---|
| 509 | */
|
---|
| 510 |
|
---|
| 511 | /*!
|
---|
| 512 | \fn Qt::MouseButtons QWheelEvent::buttons() const
|
---|
| 513 |
|
---|
| 514 | Returns the mouse state when the event occurred.
|
---|
| 515 | */
|
---|
| 516 |
|
---|
| 517 | /*!
|
---|
| 518 | \fn Qt::Orientation QWheelEvent::orientation() const
|
---|
| 519 |
|
---|
| 520 | Returns the wheel's orientation.
|
---|
| 521 | */
|
---|
| 522 |
|
---|
| 523 | /*!
|
---|
| 524 | Constructs a wheel event object.
|
---|
| 525 |
|
---|
| 526 | The position, \a pos, is the location of the mouse cursor within
|
---|
| 527 | the widget. The globalPos() is initialized to QCursor::pos()
|
---|
| 528 | which is usually, but not always, correct.
|
---|
| 529 | Use the other constructor if you need to specify the global
|
---|
| 530 | position explicitly.
|
---|
| 531 |
|
---|
| 532 | The \a buttons describe the state of the mouse buttons at the time
|
---|
| 533 | of the event, \a delta contains the rotation distance,
|
---|
| 534 | \a modifiers holds the keyboard modifier flags at the time of the
|
---|
| 535 | event, and \a orient holds the wheel's orientation.
|
---|
| 536 |
|
---|
| 537 | \sa pos() delta() state()
|
---|
| 538 | */
|
---|
| 539 | #ifndef QT_NO_WHEELEVENT
|
---|
| 540 | QWheelEvent::QWheelEvent(const QPoint &pos, int delta,
|
---|
| 541 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
---|
| 542 | Qt::Orientation orient)
|
---|
| 543 | : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient)
|
---|
| 544 | {
|
---|
| 545 | g = QCursor::pos();
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | /*!
|
---|
| 549 | \internal
|
---|
| 550 | */
|
---|
| 551 | QWheelEvent::~QWheelEvent()
|
---|
| 552 | {
|
---|
| 553 | }
|
---|
| 554 |
|
---|
| 555 | #ifdef QT3_SUPPORT
|
---|
| 556 | /*!
|
---|
| 557 | Use one of the other constructors instead.
|
---|
| 558 | */
|
---|
| 559 | QWheelEvent::QWheelEvent(const QPoint &pos, int delta, int state, Qt::Orientation orient)
|
---|
| 560 | : QInputEvent(Wheel), p(pos), d(delta), o(orient)
|
---|
| 561 | {
|
---|
| 562 | g = QCursor::pos();
|
---|
| 563 | mouseState = Qt::MouseButtons(state & Qt::MouseButtonMask);
|
---|
| 564 | modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);
|
---|
| 565 | }
|
---|
| 566 | #endif
|
---|
| 567 |
|
---|
| 568 | /*!
|
---|
| 569 | Constructs a wheel event object.
|
---|
| 570 |
|
---|
| 571 | The \a pos provides the location of the mouse cursor
|
---|
| 572 | within the widget. The position in global coordinates is specified
|
---|
| 573 | by \a globalPos. \a delta contains the rotation distance, \a modifiers
|
---|
| 574 | holds the keyboard modifier flags at the time of the event, and
|
---|
| 575 | \a orient holds the wheel's orientation.
|
---|
| 576 |
|
---|
| 577 | \sa pos() globalPos() delta() state()
|
---|
| 578 | */
|
---|
| 579 | QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
|
---|
| 580 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
---|
| 581 | Qt::Orientation orient)
|
---|
| 582 | : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient)
|
---|
| 583 | {}
|
---|
| 584 |
|
---|
| 585 | #ifdef QT3_SUPPORT
|
---|
| 586 | /*!
|
---|
| 587 | Use one of the other constructors instead.
|
---|
| 588 | */
|
---|
| 589 | QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta, int state,
|
---|
| 590 | Qt::Orientation orient)
|
---|
| 591 | : QInputEvent(Wheel), p(pos), g(globalPos), d(delta), o(orient)
|
---|
| 592 | {
|
---|
| 593 | mouseState = Qt::MouseButtons(state & Qt::MouseButtonMask);
|
---|
| 594 | modState = Qt::KeyboardModifiers(state & (int) Qt::KeyButtonMask);
|
---|
| 595 | }
|
---|
| 596 | #endif
|
---|
| 597 | #endif // QT_NO_WHEELEVENT
|
---|
| 598 |
|
---|
| 599 | /*!
|
---|
| 600 | \fn int QWheelEvent::delta() const
|
---|
| 601 |
|
---|
| 602 | Returns the distance that the wheel is rotated, in eighths of a
|
---|
| 603 | degree. A positive value indicates that the wheel was rotated
|
---|
| 604 | forwards away from the user; a negative value indicates that the
|
---|
| 605 | wheel was rotated backwards toward the user.
|
---|
| 606 |
|
---|
| 607 | Most mouse types work in steps of 15 degrees, in which case the
|
---|
| 608 | delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
|
---|
| 609 |
|
---|
| 610 | However, some mice have finer-resolution wheels and send delta values
|
---|
| 611 | that are less than 120 units (less than 15 degrees). To support this
|
---|
| 612 | possibility, you can either cumulatively add the delta values from events
|
---|
| 613 | until the value of 120 is reached, then scroll the widget, or you can
|
---|
| 614 | partially scroll the widget in response to each wheel event.
|
---|
| 615 |
|
---|
| 616 | Example:
|
---|
| 617 |
|
---|
| 618 | \snippet doc/src/snippets/code/src_gui_kernel_qevent.cpp 0
|
---|
| 619 | */
|
---|
| 620 |
|
---|
| 621 | /*!
|
---|
| 622 | \fn const QPoint &QWheelEvent::pos() const
|
---|
| 623 |
|
---|
| 624 | Returns the position of the mouse cursor relative to the widget
|
---|
| 625 | that received the event.
|
---|
| 626 |
|
---|
| 627 | If you move your widgets around in response to mouse events,
|
---|
| 628 | use globalPos() instead of this function.
|
---|
| 629 |
|
---|
| 630 | \sa x() y() globalPos()
|
---|
| 631 | */
|
---|
| 632 |
|
---|
| 633 | /*!
|
---|
| 634 | \fn int QWheelEvent::x() const
|
---|
| 635 |
|
---|
| 636 | Returns the x position of the mouse cursor, relative to the
|
---|
| 637 | widget that received the event.
|
---|
| 638 |
|
---|
| 639 | \sa y() pos()
|
---|
| 640 | */
|
---|
| 641 |
|
---|
| 642 | /*!
|
---|
| 643 | \fn int QWheelEvent::y() const
|
---|
| 644 |
|
---|
| 645 | Returns the y position of the mouse cursor, relative to the
|
---|
| 646 | widget that received the event.
|
---|
| 647 |
|
---|
| 648 | \sa x() pos()
|
---|
| 649 | */
|
---|
| 650 |
|
---|
| 651 |
|
---|
| 652 | /*!
|
---|
| 653 | \fn const QPoint &QWheelEvent::globalPos() const
|
---|
| 654 |
|
---|
| 655 | Returns the global position of the mouse pointer \e{at the time
|
---|
| 656 | of the event}. This is important on asynchronous window systems
|
---|
| 657 | such as X11; whenever you move your widgets around in response to
|
---|
| 658 | mouse events, globalPos() can differ a lot from the current
|
---|
| 659 | cursor position returned by QCursor::pos().
|
---|
| 660 |
|
---|
| 661 | \sa globalX() globalY()
|
---|
| 662 | */
|
---|
| 663 |
|
---|
| 664 | /*!
|
---|
| 665 | \fn int QWheelEvent::globalX() const
|
---|
| 666 |
|
---|
| 667 | Returns the global x position of the mouse cursor at the time of
|
---|
| 668 | the event.
|
---|
| 669 |
|
---|
| 670 | \sa globalY() globalPos()
|
---|
| 671 | */
|
---|
| 672 |
|
---|
| 673 | /*!
|
---|
| 674 | \fn int QWheelEvent::globalY() const
|
---|
| 675 |
|
---|
| 676 | Returns the global y position of the mouse cursor at the time of
|
---|
| 677 | the event.
|
---|
| 678 |
|
---|
| 679 | \sa globalX() globalPos()
|
---|
| 680 | */
|
---|
| 681 |
|
---|
| 682 |
|
---|
| 683 | /*! \obsolete
|
---|
| 684 | \fn Qt::ButtonState QWheelEvent::state() const
|
---|
| 685 |
|
---|
| 686 | Returns the keyboard modifier flags at the time of the event.
|
---|
| 687 |
|
---|
| 688 | The returned value is a selection of the following values,
|
---|
| 689 | combined using the OR operator: Qt::ShiftButton,
|
---|
| 690 | Qt::ControlButton, and Qt::AltButton.
|
---|
| 691 | */
|
---|
| 692 |
|
---|
| 693 |
|
---|
| 694 | /*!
|
---|
| 695 | \class QKeyEvent
|
---|
| 696 | \brief The QKeyEvent class describes a key event.
|
---|
| 697 |
|
---|
| 698 | \ingroup events
|
---|
| 699 |
|
---|
| 700 | Key events are sent to the widget with keyboard input focus
|
---|
| 701 | when keys are pressed or released.
|
---|
| 702 |
|
---|
| 703 | A key event contains a special accept flag that indicates whether
|
---|
| 704 | the receiver will handle the key event. You should call ignore()
|
---|
| 705 | if the key press or release event is not handled by your widget.
|
---|
| 706 | A key event is propagated up the parent widget chain until a
|
---|
| 707 | widget accepts it with accept() or an event filter consumes it.
|
---|
| 708 | Key events for multimedia keys are ignored by default. You should
|
---|
| 709 | call accept() if your widget handles those events.
|
---|
| 710 |
|
---|
| 711 | The QWidget::setEnable() function can be used to enable or disable
|
---|
| 712 | mouse and keyboard events for a widget.
|
---|
| 713 |
|
---|
[561] | 714 | The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
|
---|
| 715 | QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
|
---|
| 716 | receive key events.
|
---|
[2] | 717 |
|
---|
| 718 | \sa QFocusEvent, QWidget::grabKeyboard()
|
---|
| 719 | */
|
---|
| 720 |
|
---|
| 721 | /*!
|
---|
| 722 | Constructs a key event object.
|
---|
| 723 |
|
---|
| 724 | The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
|
---|
| 725 | or QEvent::ShortcutOverride.
|
---|
| 726 |
|
---|
[561] | 727 | Int \a key is the code for the Qt::Key that the event loop should listen
|
---|
| 728 | for. If \a key is 0, the event is not a result of a known key; for
|
---|
| 729 | example, it may be the result of a compose sequence or keyboard macro.
|
---|
| 730 | The \a modifiers holds the keyboard modifiers, and the given \a text
|
---|
| 731 | is the Unicode text that the key generated. If \a autorep is true,
|
---|
| 732 | isAutoRepeat() will be true. \a count is the number of keys involved
|
---|
| 733 | in the event.
|
---|
[2] | 734 | */
|
---|
| 735 | QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
|
---|
| 736 | bool autorep, ushort count)
|
---|
| 737 | : QInputEvent(type, modifiers), txt(text), k(key), c(count), autor(autorep)
|
---|
| 738 | {
|
---|
| 739 | }
|
---|
| 740 |
|
---|
| 741 | /*!
|
---|
| 742 | \internal
|
---|
| 743 | */
|
---|
| 744 | QKeyEvent::~QKeyEvent()
|
---|
| 745 | {
|
---|
| 746 | }
|
---|
| 747 |
|
---|
| 748 | /*!
|
---|
| 749 | \internal
|
---|
| 750 | */
|
---|
| 751 | QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
|
---|
| 752 | quint32 nativeScanCode, quint32 nativeVirtualKey,
|
---|
| 753 | quint32 nativeModifiers,
|
---|
| 754 | const QString& text, bool autorep, ushort count)
|
---|
| 755 | {
|
---|
| 756 | return new QKeyEventEx(type, key, modifiers, text, autorep, count,
|
---|
| 757 | nativeScanCode, nativeVirtualKey, nativeModifiers);
|
---|
| 758 | }
|
---|
| 759 |
|
---|
| 760 | /*!
|
---|
| 761 | \fn bool QKeyEvent::hasExtendedInfo() const
|
---|
| 762 | \internal
|
---|
| 763 | */
|
---|
| 764 |
|
---|
| 765 | /*!
|
---|
| 766 | \since 4.2
|
---|
| 767 |
|
---|
| 768 | Returns the native scan code of the key event. If the key event
|
---|
| 769 | does not contain this data 0 is returned.
|
---|
| 770 |
|
---|
| 771 | Note: The native scan code may be 0, even if the key event contains
|
---|
| 772 | extended information.
|
---|
| 773 |
|
---|
| 774 | Note: On Mac OS/X, this function is not useful, because there is no
|
---|
| 775 | way to get the scan code from Carbon or Cocoa. The function always
|
---|
| 776 | returns 1 (or 0 in the case explained above).
|
---|
| 777 | */
|
---|
| 778 | quint32 QKeyEvent::nativeScanCode() const
|
---|
| 779 | {
|
---|
| 780 | return (reinterpret_cast<const QKeyEvent*>(d) != this
|
---|
| 781 | ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nScanCode);
|
---|
| 782 | }
|
---|
| 783 |
|
---|
| 784 | /*!
|
---|
| 785 | \since 4.2
|
---|
| 786 |
|
---|
| 787 | Returns the native virtual key, or key sym of the key event.
|
---|
| 788 | If the key event does not contain this data 0 is returned.
|
---|
| 789 |
|
---|
| 790 | Note: The native virtual key may be 0, even if the key event contains extended information.
|
---|
| 791 | */
|
---|
| 792 | quint32 QKeyEvent::nativeVirtualKey() const
|
---|
| 793 | {
|
---|
| 794 | return (reinterpret_cast<const QKeyEvent*>(d) != this
|
---|
| 795 | ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nVirtualKey);
|
---|
| 796 | }
|
---|
| 797 |
|
---|
| 798 | /*!
|
---|
| 799 | \since 4.2
|
---|
| 800 |
|
---|
| 801 | Returns the native modifiers of a key event.
|
---|
| 802 | If the key event does not contain this data 0 is returned.
|
---|
| 803 |
|
---|
| 804 | Note: The native modifiers may be 0, even if the key event contains extended information.
|
---|
| 805 | */
|
---|
| 806 | quint32 QKeyEvent::nativeModifiers() const
|
---|
| 807 | {
|
---|
| 808 | return (reinterpret_cast<const QKeyEvent*>(d) != this
|
---|
| 809 | ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nModifiers);
|
---|
| 810 | }
|
---|
| 811 |
|
---|
| 812 | /*!
|
---|
| 813 | \internal
|
---|
| 814 | Creates an extended key event object, which in addition to the normal key event data, also
|
---|
| 815 | contains the native scan code, virtual key and modifiers. This extra data is used by the
|
---|
| 816 | shortcut system, to determine which shortcuts to trigger.
|
---|
| 817 | */
|
---|
| 818 | QKeyEventEx::QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,
|
---|
| 819 | const QString &text, bool autorep, ushort count,
|
---|
| 820 | quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers)
|
---|
| 821 | : QKeyEvent(type, key, modifiers, text, autorep, count),
|
---|
| 822 | nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers)
|
---|
| 823 | {
|
---|
| 824 | d = reinterpret_cast<QEventPrivate*>(this);
|
---|
| 825 | }
|
---|
| 826 |
|
---|
| 827 | /*!
|
---|
| 828 | \internal
|
---|
| 829 | Creates a copy of an other extended key event.
|
---|
| 830 | */
|
---|
| 831 | QKeyEventEx::QKeyEventEx(const QKeyEventEx &other)
|
---|
| 832 | : QKeyEvent(QEvent::Type(other.t), other.k, other.modState, other.txt, other.autor, other.c),
|
---|
| 833 | nScanCode(other.nScanCode), nVirtualKey(other.nVirtualKey), nModifiers(other.nModifiers)
|
---|
| 834 | {
|
---|
| 835 | d = reinterpret_cast<QEventPrivate*>(this);
|
---|
| 836 | }
|
---|
| 837 |
|
---|
| 838 | /*!
|
---|
| 839 | \internal
|
---|
| 840 | */
|
---|
| 841 | QKeyEventEx::~QKeyEventEx()
|
---|
| 842 | {
|
---|
| 843 | }
|
---|
| 844 |
|
---|
| 845 | /*!
|
---|
| 846 | \fn int QKeyEvent::key() const
|
---|
| 847 |
|
---|
| 848 | Returns the code of the key that was pressed or released.
|
---|
| 849 |
|
---|
| 850 | See \l Qt::Key for the list of keyboard codes. These codes are
|
---|
| 851 | independent of the underlying window system. Note that this
|
---|
| 852 | function does not distinguish between capital and non-capital
|
---|
| 853 | letters, use the text() function (returning the Unicode text the
|
---|
| 854 | key generated) for this purpose.
|
---|
| 855 |
|
---|
| 856 | A value of either 0 or Qt::Key_unknown means that the event is not
|
---|
| 857 | the result of a known key; for example, it may be the result of
|
---|
| 858 | a compose sequence, a keyboard macro, or due to key event
|
---|
| 859 | compression.
|
---|
| 860 |
|
---|
| 861 | \sa Qt::WA_KeyCompression
|
---|
| 862 | */
|
---|
| 863 |
|
---|
| 864 | /*!
|
---|
| 865 | \fn QString QKeyEvent::text() const
|
---|
| 866 |
|
---|
| 867 | Returns the Unicode text that this key generated. The text
|
---|
| 868 | returned can be an empty string in cases
|
---|
| 869 | where modifier keys, such as Shift, Control, Alt, and Meta,
|
---|
| 870 | are being pressed or released. In such cases key() will contain
|
---|
| 871 | a valid value.
|
---|
| 872 |
|
---|
| 873 | \sa Qt::WA_KeyCompression
|
---|
| 874 | */
|
---|
| 875 |
|
---|
| 876 | /*!
|
---|
| 877 | Returns the keyboard modifier flags that existed immediately
|
---|
| 878 | after the event occurred.
|
---|
| 879 |
|
---|
| 880 | \warning This function cannot always be trusted. The user can
|
---|
| 881 | confuse it by pressing both \key{Shift} keys simultaneously and
|
---|
| 882 | releasing one of them, for example.
|
---|
| 883 |
|
---|
| 884 | \sa QApplication::keyboardModifiers()
|
---|
| 885 | */
|
---|
| 886 | //###### We must check with XGetModifierMapping
|
---|
| 887 | Qt::KeyboardModifiers QKeyEvent::modifiers() const
|
---|
| 888 | {
|
---|
| 889 | if (key() == Qt::Key_Shift)
|
---|
| 890 | return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
|
---|
| 891 | if (key() == Qt::Key_Control)
|
---|
| 892 | return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
|
---|
| 893 | if (key() == Qt::Key_Alt)
|
---|
| 894 | return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
|
---|
| 895 | if (key() == Qt::Key_Meta)
|
---|
| 896 | return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
|
---|
| 897 | return QInputEvent::modifiers();
|
---|
| 898 | }
|
---|
| 899 |
|
---|
| 900 | #ifndef QT_NO_SHORTCUT
|
---|
| 901 | /*!
|
---|
| 902 | \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
|
---|
| 903 | \since 4.2
|
---|
| 904 |
|
---|
| 905 | Returns true if the key event matches the given standard \a key;
|
---|
| 906 | otherwise returns false.
|
---|
| 907 | */
|
---|
| 908 | bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
|
---|
| 909 | {
|
---|
| 910 | uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
|
---|
| 911 | uint platform = QApplicationPrivate::currentPlatform();
|
---|
| 912 |
|
---|
[561] | 913 | #ifdef Q_WS_MAC
|
---|
| 914 | if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
|
---|
| 915 | uint oldSearchKey = searchkey;
|
---|
| 916 | searchkey &= ~(Qt::ControlModifier | Qt::MetaModifier);
|
---|
| 917 | if (oldSearchKey & Qt::ControlModifier)
|
---|
| 918 | searchkey |= Qt::MetaModifier;
|
---|
| 919 | if (oldSearchKey & Qt::MetaModifier)
|
---|
| 920 | searchkey |= Qt::ControlModifier;
|
---|
| 921 | }
|
---|
| 922 | #endif
|
---|
| 923 |
|
---|
[2] | 924 | uint N = QKeySequencePrivate::numberOfKeyBindings;
|
---|
| 925 | int first = 0;
|
---|
| 926 | int last = N - 1;
|
---|
| 927 |
|
---|
| 928 | while (first <= last) {
|
---|
| 929 | int mid = (first + last) / 2;
|
---|
| 930 | QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];
|
---|
| 931 |
|
---|
| 932 | if (searchkey > midVal.shortcut){
|
---|
| 933 | first = mid + 1; // Search in top half
|
---|
| 934 | }
|
---|
| 935 | else if (searchkey < midVal.shortcut){
|
---|
| 936 | last = mid - 1; // Search in bottom half
|
---|
| 937 | }
|
---|
| 938 | else {
|
---|
| 939 | //found correct shortcut value, now we must check for platform match
|
---|
| 940 | if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {
|
---|
| 941 | return true;
|
---|
| 942 | } else { //We may have several equal values for different platforms, so we must search in both directions
|
---|
| 943 |
|
---|
| 944 | //search forward
|
---|
| 945 | for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {
|
---|
| 946 | QKeyBinding current = QKeySequencePrivate::keyBindings[i];
|
---|
| 947 | if (current.shortcut != searchkey)
|
---|
| 948 | break;
|
---|
| 949 | else if (current.platform & platform && current.standardKey == matchKey)
|
---|
| 950 | return true;
|
---|
| 951 | }
|
---|
| 952 |
|
---|
| 953 | //search back
|
---|
| 954 | for ( int i = mid - 1 ; i >= 0 ; --i) {
|
---|
| 955 | QKeyBinding current = QKeySequencePrivate::keyBindings[i];
|
---|
| 956 | if (current.shortcut != searchkey)
|
---|
| 957 | break;
|
---|
| 958 | else if (current.platform & platform && current.standardKey == matchKey)
|
---|
| 959 | return true;
|
---|
| 960 | }
|
---|
| 961 | return false; //we could not find it among the matching keySequences
|
---|
| 962 | }
|
---|
| 963 | }
|
---|
| 964 | }
|
---|
| 965 | return false; //we could not find matching keySequences at all
|
---|
| 966 | }
|
---|
| 967 | #endif // QT_NO_SHORTCUT
|
---|
| 968 |
|
---|
| 969 |
|
---|
| 970 | /*!
|
---|
| 971 | \fn bool QKeyEvent::isAutoRepeat() const
|
---|
| 972 |
|
---|
| 973 | Returns true if this event comes from an auto-repeating key;
|
---|
| 974 | returns false if it comes from an initial key press.
|
---|
| 975 |
|
---|
| 976 | Note that if the event is a multiple-key compressed event that is
|
---|
| 977 | partly due to auto-repeat, this function could return either true
|
---|
| 978 | or false indeterminately.
|
---|
| 979 | */
|
---|
| 980 |
|
---|
| 981 | /*!
|
---|
| 982 | \fn int QKeyEvent::count() const
|
---|
| 983 |
|
---|
| 984 | Returns the number of keys involved in this event. If text()
|
---|
| 985 | is not empty, this is simply the length of the string.
|
---|
| 986 |
|
---|
| 987 | \sa Qt::WA_KeyCompression
|
---|
| 988 | */
|
---|
| 989 |
|
---|
| 990 | #ifdef QT3_SUPPORT
|
---|
| 991 | /*!
|
---|
| 992 | \fn QKeyEvent::QKeyEvent(Type type, int key, int ascii,
|
---|
| 993 | int modifiers, const QString &text,
|
---|
| 994 | bool autorep, ushort count)
|
---|
| 995 |
|
---|
| 996 | Use one of the other constructors instead.
|
---|
| 997 | */
|
---|
| 998 |
|
---|
| 999 | /*!
|
---|
| 1000 | \fn int QKeyEvent::ascii() const
|
---|
| 1001 |
|
---|
| 1002 | Use text() instead.
|
---|
| 1003 | */
|
---|
| 1004 |
|
---|
| 1005 | /*!
|
---|
| 1006 | \fn Qt::ButtonState QKeyEvent::state() const
|
---|
| 1007 |
|
---|
| 1008 | Use QInputEvent::modifiers() instead.
|
---|
| 1009 | */
|
---|
| 1010 |
|
---|
| 1011 | /*!
|
---|
| 1012 | \fn Qt::ButtonState QKeyEvent::stateAfter() const
|
---|
| 1013 |
|
---|
| 1014 | Use modifiers() instead.
|
---|
| 1015 | */
|
---|
| 1016 | #endif
|
---|
| 1017 |
|
---|
| 1018 | /*!
|
---|
| 1019 | \class QFocusEvent
|
---|
| 1020 | \brief The QFocusEvent class contains event parameters for widget focus
|
---|
| 1021 | events.
|
---|
| 1022 |
|
---|
| 1023 | \ingroup events
|
---|
| 1024 |
|
---|
| 1025 | Focus events are sent to widgets when the keyboard input focus
|
---|
| 1026 | changes. Focus events occur due to mouse actions, key presses
|
---|
| 1027 | (such as \gui{Tab} or \gui{Backtab}), the window system, popup
|
---|
| 1028 | menus, keyboard shortcuts, or other application-specific reasons.
|
---|
| 1029 | The reason for a particular focus event is returned by reason()
|
---|
| 1030 | in the appropriate event handler.
|
---|
| 1031 |
|
---|
[561] | 1032 | The event handlers QWidget::focusInEvent(),
|
---|
| 1033 | QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
|
---|
| 1034 | QGraphicsItem::focusOutEvent() receive focus events.
|
---|
[2] | 1035 |
|
---|
| 1036 | \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
|
---|
| 1037 | */
|
---|
| 1038 |
|
---|
| 1039 | /*!
|
---|
| 1040 | Constructs a focus event object.
|
---|
| 1041 |
|
---|
| 1042 | The \a type parameter must be either QEvent::FocusIn or
|
---|
| 1043 | QEvent::FocusOut. The \a reason describes the cause of the change
|
---|
| 1044 | in focus.
|
---|
| 1045 | */
|
---|
| 1046 | QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
|
---|
| 1047 | : QEvent(type), m_reason(reason)
|
---|
| 1048 | {}
|
---|
| 1049 |
|
---|
| 1050 | /*!
|
---|
| 1051 | \internal
|
---|
| 1052 | */
|
---|
| 1053 | QFocusEvent::~QFocusEvent()
|
---|
| 1054 | {
|
---|
| 1055 | }
|
---|
| 1056 |
|
---|
| 1057 | // ### Qt 5: remove
|
---|
| 1058 | /*!
|
---|
| 1059 | \internal
|
---|
| 1060 | */
|
---|
| 1061 | Qt::FocusReason QFocusEvent::reason()
|
---|
| 1062 | {
|
---|
| 1063 | return m_reason;
|
---|
| 1064 | }
|
---|
| 1065 |
|
---|
| 1066 | /*!
|
---|
| 1067 | Returns the reason for this focus event.
|
---|
| 1068 | */
|
---|
| 1069 | Qt::FocusReason QFocusEvent::reason() const
|
---|
| 1070 | {
|
---|
| 1071 | return m_reason;
|
---|
| 1072 | }
|
---|
| 1073 |
|
---|
| 1074 | /*!
|
---|
| 1075 | \fn bool QFocusEvent::gotFocus() const
|
---|
| 1076 |
|
---|
| 1077 | Returns true if type() is QEvent::FocusIn; otherwise returns
|
---|
| 1078 | false.
|
---|
| 1079 | */
|
---|
| 1080 |
|
---|
| 1081 | /*!
|
---|
| 1082 | \fn bool QFocusEvent::lostFocus() const
|
---|
| 1083 |
|
---|
| 1084 | Returns true if type() is QEvent::FocusOut; otherwise returns
|
---|
| 1085 | false.
|
---|
| 1086 | */
|
---|
| 1087 |
|
---|
| 1088 | #ifdef QT3_SUPPORT
|
---|
| 1089 | /*!
|
---|
| 1090 | \enum QFocusEvent::Reason
|
---|
| 1091 | \compat
|
---|
| 1092 |
|
---|
| 1093 | Use Qt::FocusReason instead.
|
---|
| 1094 |
|
---|
| 1095 | \value Mouse Same as Qt::MouseFocusReason.
|
---|
| 1096 | \value Tab Same as Qt::TabFocusReason.
|
---|
| 1097 | \value Backtab Same as Qt::BacktabFocusReason.
|
---|
| 1098 | \value MenuBar Same as Qt::MenuBarFocusReason.
|
---|
| 1099 | \value ActiveWindow Same as Qt::ActiveWindowFocusReason
|
---|
| 1100 | \value Other Same as Qt::OtherFocusReason
|
---|
| 1101 | \value Popup Same as Qt::PopupFocusReason
|
---|
| 1102 | \value Shortcut Same as Qt::ShortcutFocusReason
|
---|
| 1103 | */
|
---|
| 1104 | #endif
|
---|
| 1105 |
|
---|
| 1106 | /*!
|
---|
| 1107 | \class QPaintEvent
|
---|
| 1108 | \brief The QPaintEvent class contains event parameters for paint events.
|
---|
| 1109 |
|
---|
| 1110 | \ingroup events
|
---|
| 1111 |
|
---|
| 1112 | Paint events are sent to widgets that need to update themselves,
|
---|
| 1113 | for instance when part of a widget is exposed because a covering
|
---|
| 1114 | widget was moved.
|
---|
| 1115 |
|
---|
| 1116 | The event contains a region() that needs to be updated, and a
|
---|
| 1117 | rect() that is the bounding rectangle of that region. Both are
|
---|
| 1118 | provided because many widgets can't make much use of region(),
|
---|
| 1119 | and rect() can be much faster than region().boundingRect().
|
---|
[561] | 1120 |
|
---|
| 1121 | \section1 Automatic Clipping
|
---|
| 1122 |
|
---|
[2] | 1123 | Painting is clipped to region() during the processing of a paint
|
---|
[561] | 1124 | event. This clipping is performed by Qt's paint system and is
|
---|
| 1125 | independent of any clipping that may be applied to a QPainter used to
|
---|
| 1126 | draw on the paint device.
|
---|
[2] | 1127 |
|
---|
[561] | 1128 | As a result, the value returned by QPainter::clipRegion() on
|
---|
| 1129 | a newly-constructed QPainter will not reflect the clip region that is
|
---|
| 1130 | used by the paint system.
|
---|
| 1131 |
|
---|
[2] | 1132 | \sa QPainter, QWidget::update(), QWidget::repaint(),
|
---|
| 1133 | QWidget::paintEvent()
|
---|
| 1134 | */
|
---|
| 1135 |
|
---|
| 1136 | /*!
|
---|
| 1137 | \fn bool QPaintEvent::erased() const
|
---|
| 1138 | \compat
|
---|
| 1139 |
|
---|
| 1140 | Returns true if the paint event region (or rectangle) has been
|
---|
| 1141 | erased with the widget's background; otherwise returns false.
|
---|
| 1142 |
|
---|
| 1143 | Qt 4 \e always erases regions that require painting. The exception
|
---|
| 1144 | to this rule is if the widget sets the Qt::WA_OpaquePaintEvent or
|
---|
| 1145 | Qt::WA_NoSystemBackground attributes. If either one of those
|
---|
| 1146 | attributes is set \e and the window system does not make use of
|
---|
| 1147 | subwidget alpha composition (currently X11 and Windows, but this
|
---|
| 1148 | may change), then the region is not erased.
|
---|
| 1149 | */
|
---|
| 1150 |
|
---|
| 1151 | /*!
|
---|
| 1152 | \fn void QPaintEvent::setErased(bool b) { m_erased = b; }
|
---|
| 1153 | \internal
|
---|
| 1154 | */
|
---|
| 1155 |
|
---|
| 1156 | /*!
|
---|
| 1157 | Constructs a paint event object with the region that needs to
|
---|
| 1158 | be updated. The region is specified by \a paintRegion.
|
---|
| 1159 | */
|
---|
| 1160 | QPaintEvent::QPaintEvent(const QRegion& paintRegion)
|
---|
| 1161 | : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
|
---|
| 1162 | {}
|
---|
| 1163 |
|
---|
| 1164 | /*!
|
---|
| 1165 | Constructs a paint event object with the rectangle that needs
|
---|
| 1166 | to be updated. The region is specified by \a paintRect.
|
---|
| 1167 | */
|
---|
| 1168 | QPaintEvent::QPaintEvent(const QRect &paintRect)
|
---|
| 1169 | : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
|
---|
| 1170 | {}
|
---|
| 1171 |
|
---|
| 1172 |
|
---|
| 1173 | #ifdef QT3_SUPPORT
|
---|
| 1174 | /*!
|
---|
| 1175 | Constructs a paint event object with both a \a paintRegion and a
|
---|
| 1176 | \a paintRect, both of which represent the area of the widget that
|
---|
| 1177 | needs to be updated.
|
---|
| 1178 |
|
---|
| 1179 | */
|
---|
| 1180 | QPaintEvent::QPaintEvent(const QRegion &paintRegion, const QRect &paintRect)
|
---|
| 1181 | : QEvent(Paint), m_rect(paintRect), m_region(paintRegion), m_erased(false)
|
---|
| 1182 | {}
|
---|
| 1183 | #endif
|
---|
| 1184 |
|
---|
| 1185 | /*!
|
---|
| 1186 | \internal
|
---|
| 1187 | */
|
---|
| 1188 | QPaintEvent::~QPaintEvent()
|
---|
| 1189 | {
|
---|
| 1190 | }
|
---|
| 1191 |
|
---|
| 1192 | /*!
|
---|
| 1193 | \fn const QRect &QPaintEvent::rect() const
|
---|
| 1194 |
|
---|
| 1195 | Returns the rectangle that needs to be updated.
|
---|
| 1196 |
|
---|
| 1197 | \sa region() QPainter::setClipRect()
|
---|
| 1198 | */
|
---|
| 1199 |
|
---|
| 1200 | /*!
|
---|
| 1201 | \fn const QRegion &QPaintEvent::region() const
|
---|
| 1202 |
|
---|
| 1203 | Returns the region that needs to be updated.
|
---|
| 1204 |
|
---|
| 1205 | \sa rect() QPainter::setClipRegion()
|
---|
| 1206 | */
|
---|
| 1207 |
|
---|
| 1208 |
|
---|
| 1209 | QUpdateLaterEvent::QUpdateLaterEvent(const QRegion& paintRegion)
|
---|
| 1210 | : QEvent(UpdateLater), m_region(paintRegion)
|
---|
| 1211 | {
|
---|
| 1212 | }
|
---|
| 1213 |
|
---|
| 1214 | QUpdateLaterEvent::~QUpdateLaterEvent()
|
---|
| 1215 | {
|
---|
| 1216 | }
|
---|
| 1217 |
|
---|
| 1218 | /*!
|
---|
| 1219 | \class QMoveEvent
|
---|
| 1220 | \brief The QMoveEvent class contains event parameters for move events.
|
---|
| 1221 |
|
---|
| 1222 | \ingroup events
|
---|
| 1223 |
|
---|
| 1224 | Move events are sent to widgets that have been moved to a new
|
---|
| 1225 | position relative to their parent.
|
---|
| 1226 |
|
---|
| 1227 | The event handler QWidget::moveEvent() receives move events.
|
---|
| 1228 |
|
---|
| 1229 | \sa QWidget::move(), QWidget::setGeometry()
|
---|
| 1230 | */
|
---|
| 1231 |
|
---|
| 1232 | /*!
|
---|
| 1233 | Constructs a move event with the new and old widget positions,
|
---|
| 1234 | \a pos and \a oldPos respectively.
|
---|
| 1235 | */
|
---|
| 1236 | QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
|
---|
| 1237 | : QEvent(Move), p(pos), oldp(oldPos)
|
---|
| 1238 | {}
|
---|
| 1239 |
|
---|
| 1240 | /*!
|
---|
| 1241 | \internal
|
---|
| 1242 | */
|
---|
| 1243 | QMoveEvent::~QMoveEvent()
|
---|
| 1244 | {
|
---|
| 1245 | }
|
---|
| 1246 |
|
---|
| 1247 | /*!
|
---|
| 1248 | \fn const QPoint &QMoveEvent::pos() const
|
---|
| 1249 |
|
---|
| 1250 | Returns the new position of the widget. This excludes the window
|
---|
| 1251 | frame for top level widgets.
|
---|
| 1252 | */
|
---|
| 1253 |
|
---|
| 1254 | /*!
|
---|
| 1255 | \fn const QPoint &QMoveEvent::oldPos() const
|
---|
| 1256 |
|
---|
| 1257 | Returns the old position of the widget.
|
---|
| 1258 | */
|
---|
| 1259 |
|
---|
| 1260 |
|
---|
| 1261 | /*!
|
---|
| 1262 | \class QResizeEvent
|
---|
| 1263 | \brief The QResizeEvent class contains event parameters for resize events.
|
---|
| 1264 |
|
---|
| 1265 | \ingroup events
|
---|
| 1266 |
|
---|
| 1267 | Resize events are sent to widgets that have been resized.
|
---|
| 1268 |
|
---|
| 1269 | The event handler QWidget::resizeEvent() receives resize events.
|
---|
| 1270 |
|
---|
| 1271 | \sa QWidget::resize() QWidget::setGeometry()
|
---|
| 1272 | */
|
---|
| 1273 |
|
---|
| 1274 | /*!
|
---|
| 1275 | Constructs a resize event with the new and old widget sizes, \a
|
---|
| 1276 | size and \a oldSize respectively.
|
---|
| 1277 | */
|
---|
| 1278 | QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
|
---|
| 1279 | : QEvent(Resize), s(size), olds(oldSize)
|
---|
| 1280 | {}
|
---|
| 1281 |
|
---|
| 1282 | /*!
|
---|
| 1283 | \internal
|
---|
| 1284 | */
|
---|
| 1285 | QResizeEvent::~QResizeEvent()
|
---|
| 1286 | {
|
---|
| 1287 | }
|
---|
| 1288 |
|
---|
| 1289 | /*!
|
---|
| 1290 | \fn const QSize &QResizeEvent::size() const
|
---|
| 1291 |
|
---|
| 1292 | Returns the new size of the widget. This is the same as
|
---|
| 1293 | QWidget::size().
|
---|
| 1294 | */
|
---|
| 1295 |
|
---|
| 1296 | /*!
|
---|
| 1297 | \fn const QSize &QResizeEvent::oldSize() const
|
---|
| 1298 |
|
---|
| 1299 | Returns the old size of the widget.
|
---|
| 1300 | */
|
---|
| 1301 |
|
---|
| 1302 |
|
---|
| 1303 | /*!
|
---|
| 1304 | \class QCloseEvent
|
---|
| 1305 | \brief The QCloseEvent class contains parameters that describe a close event.
|
---|
| 1306 |
|
---|
| 1307 | \ingroup events
|
---|
| 1308 |
|
---|
| 1309 | Close events are sent to widgets that the user wants to close,
|
---|
| 1310 | usually by choosing "Close" from the window menu, or by clicking
|
---|
| 1311 | the \gui{X} title bar button. They are also sent when you call
|
---|
| 1312 | QWidget::close() to close a widget programmatically.
|
---|
| 1313 |
|
---|
| 1314 | Close events contain a flag that indicates whether the receiver
|
---|
| 1315 | wants the widget to be closed or not. When a widget accepts the
|
---|
| 1316 | close event, it is hidden (and destroyed if it was created with
|
---|
| 1317 | the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
|
---|
| 1318 | event nothing happens. (Under X11 it is possible that the window
|
---|
| 1319 | manager will forcibly close the window; but at the time of writing
|
---|
| 1320 | we are not aware of any window manager that does this.)
|
---|
| 1321 |
|
---|
| 1322 | The event handler QWidget::closeEvent() receives close events. The
|
---|
| 1323 | default implementation of this event handler accepts the close
|
---|
| 1324 | event. If you do not want your widget to be hidden, or want some
|
---|
| 1325 | special handing, you should reimplement the event handler and
|
---|
| 1326 | ignore() the event.
|
---|
| 1327 |
|
---|
| 1328 | The \l{mainwindows/application#close event handler}{closeEvent() in the
|
---|
| 1329 | Application example} shows a close event handler that
|
---|
| 1330 | asks whether to save a document before closing.
|
---|
| 1331 |
|
---|
| 1332 | If you want the widget to be deleted when it is closed, create it
|
---|
| 1333 | with the Qt::WA_DeleteOnClose flag. This is very useful for
|
---|
| 1334 | independent top-level windows in a multi-window application.
|
---|
| 1335 |
|
---|
| 1336 | \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
|
---|
| 1337 | signal when they are deleted.
|
---|
| 1338 |
|
---|
| 1339 | If the last top-level window is closed, the
|
---|
| 1340 | QApplication::lastWindowClosed() signal is emitted.
|
---|
| 1341 |
|
---|
| 1342 | The isAccepted() function returns true if the event's receiver has
|
---|
| 1343 | agreed to close the widget; call accept() to agree to close the
|
---|
| 1344 | widget and call ignore() if the receiver of this event does not
|
---|
| 1345 | want the widget to be closed.
|
---|
| 1346 |
|
---|
| 1347 | \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
|
---|
| 1348 | QCoreApplication::exec(), QCoreApplication::quit(),
|
---|
| 1349 | QApplication::lastWindowClosed()
|
---|
| 1350 | */
|
---|
| 1351 |
|
---|
| 1352 | /*!
|
---|
| 1353 | Constructs a close event object.
|
---|
| 1354 |
|
---|
| 1355 | \sa accept()
|
---|
| 1356 | */
|
---|
| 1357 | QCloseEvent::QCloseEvent()
|
---|
| 1358 | : QEvent(Close)
|
---|
| 1359 | {}
|
---|
| 1360 |
|
---|
| 1361 | /*! \internal
|
---|
| 1362 | */
|
---|
| 1363 | QCloseEvent::~QCloseEvent()
|
---|
| 1364 | {
|
---|
| 1365 | }
|
---|
| 1366 |
|
---|
| 1367 | /*!
|
---|
| 1368 | \class QIconDragEvent
|
---|
| 1369 | \brief The QIconDragEvent class indicates that a main icon drag has begun.
|
---|
| 1370 |
|
---|
| 1371 | \ingroup events
|
---|
| 1372 |
|
---|
| 1373 | Icon drag events are sent to widgets when the main icon of a window
|
---|
| 1374 | has been dragged away. On Mac OS X, this happens when the proxy
|
---|
| 1375 | icon of a window is dragged off the title bar.
|
---|
| 1376 |
|
---|
| 1377 | It is normal to begin using drag and drop in response to this
|
---|
| 1378 | event.
|
---|
| 1379 |
|
---|
| 1380 | \sa {Drag and Drop}, QMimeData, QDrag
|
---|
| 1381 | */
|
---|
| 1382 |
|
---|
| 1383 | /*!
|
---|
| 1384 | Constructs an icon drag event object with the accept flag set to
|
---|
| 1385 | false.
|
---|
| 1386 |
|
---|
| 1387 | \sa accept()
|
---|
| 1388 | */
|
---|
| 1389 | QIconDragEvent::QIconDragEvent()
|
---|
| 1390 | : QEvent(IconDrag)
|
---|
| 1391 | { ignore(); }
|
---|
| 1392 |
|
---|
| 1393 | /*! \internal */
|
---|
| 1394 | QIconDragEvent::~QIconDragEvent()
|
---|
| 1395 | {
|
---|
| 1396 | }
|
---|
| 1397 |
|
---|
| 1398 | /*!
|
---|
| 1399 | \class QContextMenuEvent
|
---|
| 1400 | \brief The QContextMenuEvent class contains parameters that describe a context menu event.
|
---|
| 1401 |
|
---|
| 1402 | \ingroup events
|
---|
| 1403 |
|
---|
| 1404 | Context menu events are sent to widgets when a user performs
|
---|
| 1405 | an action associated with opening a context menu.
|
---|
| 1406 | The actions required to open context menus vary between platforms;
|
---|
| 1407 | for example, on Windows, pressing the menu button or clicking the
|
---|
| 1408 | right mouse button will cause this event to be sent.
|
---|
| 1409 |
|
---|
| 1410 | When this event occurs it is customary to show a QMenu with a
|
---|
| 1411 | context menu, if this is relevant to the context.
|
---|
| 1412 |
|
---|
| 1413 | Context menu events contain a special accept flag that indicates
|
---|
| 1414 | whether the receiver accepted the event. If the event handler does
|
---|
| 1415 | not accept the event then, if possible, whatever triggered the event will be
|
---|
| 1416 | handled as a regular input event.
|
---|
| 1417 | */
|
---|
| 1418 |
|
---|
| 1419 | #ifndef QT_NO_CONTEXTMENU
|
---|
| 1420 | /*!
|
---|
| 1421 | Constructs a context menu event object with the accept parameter
|
---|
| 1422 | flag set to false.
|
---|
| 1423 |
|
---|
| 1424 | The \a reason parameter must be QContextMenuEvent::Mouse or
|
---|
| 1425 | QContextMenuEvent::Keyboard.
|
---|
| 1426 |
|
---|
| 1427 | The \a pos parameter specifies the mouse position relative to the
|
---|
| 1428 | receiving widget. \a globalPos is the mouse position in absolute
|
---|
| 1429 | coordinates.
|
---|
| 1430 | */
|
---|
| 1431 | QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
|
---|
| 1432 | : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
|
---|
| 1433 | {}
|
---|
| 1434 |
|
---|
| 1435 | /*!
|
---|
| 1436 | Constructs a context menu event object with the accept parameter
|
---|
| 1437 | flag set to false.
|
---|
| 1438 |
|
---|
| 1439 | The \a reason parameter must be QContextMenuEvent::Mouse or
|
---|
| 1440 | QContextMenuEvent::Keyboard.
|
---|
| 1441 |
|
---|
| 1442 | The \a pos parameter specifies the mouse position relative to the
|
---|
| 1443 | receiving widget. \a globalPos is the mouse position in absolute
|
---|
| 1444 | coordinates. The \a modifiers holds the keyboard modifiers.
|
---|
| 1445 | */
|
---|
| 1446 | QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
|
---|
| 1447 | Qt::KeyboardModifiers modifiers)
|
---|
| 1448 | : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
|
---|
| 1449 | {}
|
---|
| 1450 |
|
---|
| 1451 | #ifdef QT3_SUPPORT
|
---|
| 1452 | /*!
|
---|
| 1453 | Constructs a context menu event with the given \a reason for the
|
---|
| 1454 | position specified by \a pos in widget coordinates and \a globalPos
|
---|
| 1455 | in global screen coordinates. \a dummy is ignored.
|
---|
| 1456 | */
|
---|
| 1457 | QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
|
---|
| 1458 | int /* dummy */)
|
---|
| 1459 | : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
|
---|
| 1460 | {}
|
---|
| 1461 | #endif
|
---|
| 1462 |
|
---|
| 1463 | /*! \internal */
|
---|
| 1464 | QContextMenuEvent::~QContextMenuEvent()
|
---|
| 1465 | {
|
---|
| 1466 | }
|
---|
| 1467 | /*!
|
---|
| 1468 | Constructs a context menu event object with the accept parameter
|
---|
| 1469 | flag set to false.
|
---|
| 1470 |
|
---|
| 1471 | The \a reason parameter must be QContextMenuEvent::Mouse or
|
---|
| 1472 | QContextMenuEvent::Keyboard.
|
---|
| 1473 |
|
---|
| 1474 | The \a pos parameter specifies the mouse position relative to the
|
---|
| 1475 | receiving widget.
|
---|
| 1476 |
|
---|
| 1477 | The globalPos() is initialized to QCursor::pos(), which may not be
|
---|
| 1478 | appropriate. Use the other constructor to specify the global
|
---|
| 1479 | position explicitly.
|
---|
| 1480 | */
|
---|
| 1481 | QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
|
---|
| 1482 | : QInputEvent(ContextMenu), p(pos), reas(reason)
|
---|
| 1483 | {
|
---|
| 1484 | gp = QCursor::pos();
|
---|
| 1485 | }
|
---|
| 1486 |
|
---|
| 1487 | #ifdef QT3_SUPPORT
|
---|
| 1488 | /*!
|
---|
| 1489 | Constructs a context menu event with the given \a reason for the
|
---|
| 1490 | position specified by \a pos in widget coordinates. \a dummy is
|
---|
| 1491 | ignored.
|
---|
| 1492 | */
|
---|
| 1493 | QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, int /* dummy */)
|
---|
| 1494 | : QInputEvent(ContextMenu), p(pos), reas(reason)
|
---|
| 1495 | {
|
---|
| 1496 | gp = QCursor::pos();
|
---|
| 1497 | }
|
---|
| 1498 |
|
---|
| 1499 | Qt::ButtonState QContextMenuEvent::state() const
|
---|
| 1500 | {
|
---|
| 1501 | return Qt::ButtonState(int(QApplication::keyboardModifiers())|QApplication::mouseButtons());
|
---|
| 1502 | }
|
---|
| 1503 | #endif
|
---|
| 1504 |
|
---|
| 1505 | /*!
|
---|
| 1506 | \fn const QPoint &QContextMenuEvent::pos() const
|
---|
| 1507 |
|
---|
| 1508 | Returns the position of the mouse pointer relative to the widget
|
---|
| 1509 | that received the event.
|
---|
| 1510 |
|
---|
| 1511 | \sa x(), y(), globalPos()
|
---|
| 1512 | */
|
---|
| 1513 |
|
---|
| 1514 | /*!
|
---|
| 1515 | \fn int QContextMenuEvent::x() const
|
---|
| 1516 |
|
---|
| 1517 | Returns the x position of the mouse pointer, relative to the
|
---|
| 1518 | widget that received the event.
|
---|
| 1519 |
|
---|
| 1520 | \sa y(), pos()
|
---|
| 1521 | */
|
---|
| 1522 |
|
---|
| 1523 | /*!
|
---|
| 1524 | \fn int QContextMenuEvent::y() const
|
---|
| 1525 |
|
---|
| 1526 | Returns the y position of the mouse pointer, relative to the
|
---|
| 1527 | widget that received the event.
|
---|
| 1528 |
|
---|
| 1529 | \sa x(), pos()
|
---|
| 1530 | */
|
---|
| 1531 |
|
---|
| 1532 | /*!
|
---|
| 1533 | \fn const QPoint &QContextMenuEvent::globalPos() const
|
---|
| 1534 |
|
---|
| 1535 | Returns the global position of the mouse pointer at the time of
|
---|
| 1536 | the event.
|
---|
| 1537 |
|
---|
| 1538 | \sa x(), y(), pos()
|
---|
| 1539 | */
|
---|
| 1540 |
|
---|
| 1541 | /*!
|
---|
| 1542 | \fn int QContextMenuEvent::globalX() const
|
---|
| 1543 |
|
---|
| 1544 | Returns the global x position of the mouse pointer at the time of
|
---|
| 1545 | the event.
|
---|
| 1546 |
|
---|
| 1547 | \sa globalY(), globalPos()
|
---|
| 1548 | */
|
---|
| 1549 |
|
---|
| 1550 | /*!
|
---|
| 1551 | \fn int QContextMenuEvent::globalY() const
|
---|
| 1552 |
|
---|
| 1553 | Returns the global y position of the mouse pointer at the time of
|
---|
| 1554 | the event.
|
---|
| 1555 |
|
---|
| 1556 | \sa globalX(), globalPos()
|
---|
| 1557 | */
|
---|
| 1558 | #endif // QT_NO_CONTEXTMENU
|
---|
| 1559 |
|
---|
| 1560 | /*!
|
---|
| 1561 | \fn Qt::ButtonState QContextMenuEvent::state() const
|
---|
| 1562 |
|
---|
| 1563 | Returns the button state (a combination of mouse buttons
|
---|
| 1564 | and keyboard modifiers) immediately before the event was
|
---|
| 1565 | generated.
|
---|
| 1566 |
|
---|
| 1567 | The returned value is a selection of the following values,
|
---|
| 1568 | combined with the OR operator:
|
---|
| 1569 | Qt::LeftButton, Qt::RightButton, Qt::MidButton,
|
---|
| 1570 | Qt::ShiftButton, Qt::ControlButton, and Qt::AltButton.
|
---|
| 1571 | */
|
---|
| 1572 |
|
---|
| 1573 | /*!
|
---|
| 1574 | \enum QContextMenuEvent::Reason
|
---|
| 1575 |
|
---|
| 1576 | This enum describes the reason why the event was sent.
|
---|
| 1577 |
|
---|
| 1578 | \value Mouse The mouse caused the event to be sent. Normally this
|
---|
| 1579 | means the right mouse button was clicked, but this is platform
|
---|
| 1580 | dependent.
|
---|
| 1581 |
|
---|
| 1582 | \value Keyboard The keyboard caused this event to be sent. On
|
---|
| 1583 | Windows, this means the menu button was pressed.
|
---|
| 1584 |
|
---|
| 1585 | \value Other The event was sent by some other means (i.e. not by
|
---|
| 1586 | the mouse or keyboard).
|
---|
| 1587 | */
|
---|
| 1588 |
|
---|
| 1589 |
|
---|
| 1590 | /*!
|
---|
| 1591 | \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
|
---|
| 1592 |
|
---|
| 1593 | Returns the reason for this context event.
|
---|
| 1594 | */
|
---|
| 1595 |
|
---|
| 1596 |
|
---|
| 1597 | /*!
|
---|
| 1598 | \class QInputMethodEvent
|
---|
| 1599 | \brief The QInputMethodEvent class provides parameters for input method events.
|
---|
| 1600 |
|
---|
| 1601 | \ingroup events
|
---|
| 1602 |
|
---|
| 1603 | Input method events are sent to widgets when an input method is
|
---|
| 1604 | used to enter text into a widget. Input methods are widely used
|
---|
| 1605 | to enter text for languages with non-Latin alphabets.
|
---|
| 1606 |
|
---|
| 1607 | Note that when creating custom text editing widgets, the
|
---|
| 1608 | Qt::WA_InputMethodEnabled window attribute must be set explicitly
|
---|
| 1609 | (using the QWidget::setAttribute() function) in order to receive
|
---|
| 1610 | input method events.
|
---|
| 1611 |
|
---|
| 1612 | The events are of interest to authors of keyboard entry widgets
|
---|
| 1613 | who want to be able to correctly handle languages with complex
|
---|
| 1614 | character input. Text input in such languages is usually a three
|
---|
| 1615 | step process:
|
---|
| 1616 |
|
---|
| 1617 | \list 1
|
---|
| 1618 | \o \bold{Starting to Compose}
|
---|
| 1619 |
|
---|
| 1620 | When the user presses the first key on a keyboard, an input
|
---|
| 1621 | context is created. This input context will contain a string
|
---|
| 1622 | of the typed characters.
|
---|
| 1623 |
|
---|
| 1624 | \o \bold{Composing}
|
---|
| 1625 |
|
---|
| 1626 | With every new key pressed, the input method will try to create a
|
---|
| 1627 | matching string for the text typed so far called preedit
|
---|
| 1628 | string. While the input context is active, the user can only move
|
---|
| 1629 | the cursor inside the string belonging to this input context.
|
---|
| 1630 |
|
---|
| 1631 | \o \bold{Completing}
|
---|
| 1632 |
|
---|
| 1633 | At some point, the user will activate a user interface component
|
---|
| 1634 | (perhaps using a particular key) where they can choose from a
|
---|
| 1635 | number of strings matching the text they have typed so far. The
|
---|
| 1636 | user can either confirm their choice cancel the input; in either
|
---|
| 1637 | case the input context will be closed.
|
---|
| 1638 | \endlist
|
---|
| 1639 |
|
---|
| 1640 | QInputMethodEvent models these three stages, and transfers the
|
---|
| 1641 | information needed to correctly render the intermediate result. A
|
---|
| 1642 | QInputMethodEvent has two main parameters: preeditString() and
|
---|
| 1643 | commitString(). The preeditString() parameter gives the currently
|
---|
| 1644 | active preedit string. The commitString() parameter gives a text
|
---|
| 1645 | that should get added to (or replace parts of) the text of the
|
---|
| 1646 | editor widget. It usually is a result of the input operations and
|
---|
| 1647 | has to be inserted to the widgets text directly before the preedit
|
---|
| 1648 | string.
|
---|
| 1649 |
|
---|
| 1650 | If the commitString() should replace parts of the of the text in
|
---|
| 1651 | the editor, replacementLength() will contain the number of
|
---|
| 1652 | characters to be replaced. replacementStart() contains the position
|
---|
| 1653 | at which characters are to be replaced relative from the start of
|
---|
| 1654 | the preedit string.
|
---|
| 1655 |
|
---|
| 1656 | A number of attributes control the visual appearance of the
|
---|
| 1657 | preedit string (the visual appearance of text outside the preedit
|
---|
| 1658 | string is controlled by the widget only). The AttributeType enum
|
---|
| 1659 | describes the different attributes that can be set.
|
---|
| 1660 |
|
---|
[561] | 1661 | A class implementing QWidget::inputMethodEvent() or
|
---|
| 1662 | QGraphicsItem::inputMethodEvent() should at least understand and
|
---|
| 1663 | honor the \l TextFormat and \l Cursor attributes.
|
---|
[2] | 1664 |
|
---|
| 1665 | Since input methods need to be able to query certain properties
|
---|
[561] | 1666 | from the widget or graphics item, subclasses must also implement
|
---|
| 1667 | QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
|
---|
| 1668 | respectively.
|
---|
[2] | 1669 |
|
---|
| 1670 | When receiving an input method event, the text widget has to performs the
|
---|
| 1671 | following steps:
|
---|
| 1672 |
|
---|
| 1673 | \list 1
|
---|
| 1674 | \o If the widget has selected text, the selected text should get
|
---|
| 1675 | removed.
|
---|
| 1676 |
|
---|
| 1677 | \o Remove the text starting at replacementStart() with length
|
---|
| 1678 | replacementLength() and replace it by the commitString(). If
|
---|
| 1679 | replacementLength() is 0, replacementStart() gives the insertion
|
---|
| 1680 | position for the commitString().
|
---|
| 1681 |
|
---|
| 1682 | When doing replacement the area of the preedit
|
---|
| 1683 | string is ignored, thus a replacement starting at -1 with a length
|
---|
| 1684 | of 2 will remove the last character before the preedit string and
|
---|
| 1685 | the first character afterwards, and insert the commit string
|
---|
| 1686 | directly before the preedit string.
|
---|
| 1687 |
|
---|
| 1688 | If the widget implements undo/redo, this operation gets added to
|
---|
| 1689 | the undo stack.
|
---|
| 1690 |
|
---|
| 1691 | \o If there is no current preedit string, insert the
|
---|
| 1692 | preeditString() at the current cursor position; otherwise replace
|
---|
| 1693 | the previous preeditString with the one received from this event.
|
---|
| 1694 |
|
---|
| 1695 | If the widget implements undo/redo, the preeditString() should not
|
---|
| 1696 | influence the undo/redo stack in any way.
|
---|
| 1697 |
|
---|
| 1698 | The widget should examine the list of attributes to apply to the
|
---|
| 1699 | preedit string. It has to understand at least the TextFormat and
|
---|
| 1700 | Cursor attributes and render them as specified.
|
---|
| 1701 | \endlist
|
---|
| 1702 |
|
---|
| 1703 | \sa QInputContext
|
---|
| 1704 | */
|
---|
| 1705 |
|
---|
| 1706 | /*!
|
---|
| 1707 | \enum QInputMethodEvent::AttributeType
|
---|
| 1708 |
|
---|
| 1709 | \value TextFormat
|
---|
| 1710 | A QTextCharFormat for the part of the preedit string specified by
|
---|
| 1711 | start and length. value contains a QVariant of type QTextFormat
|
---|
| 1712 | specifying rendering of this part of the preedit string. There
|
---|
| 1713 | should be at most one format for every part of the preedit
|
---|
| 1714 | string. If several are specified for any character in the string the
|
---|
| 1715 | behaviour is undefined. A conforming implementation has to at least
|
---|
| 1716 | honor the backgroundColor, textColor and fontUnderline properties
|
---|
| 1717 | of the format.
|
---|
| 1718 |
|
---|
| 1719 | \value Cursor If set, a cursor should be shown inside the preedit
|
---|
| 1720 | string at position start. The length variable determines whether
|
---|
| 1721 | the cursor is visible or not. If the length is 0 the cursor is
|
---|
| 1722 | invisible. If value is a QVariant of type QColor this color will
|
---|
| 1723 | be used for rendering the cursor, otherwise the color of the
|
---|
| 1724 | surrounding text will be used. There should be at most one Cursor
|
---|
| 1725 | attribute per event. If several are specified the behaviour is
|
---|
| 1726 | undefined.
|
---|
| 1727 |
|
---|
| 1728 | \value Language
|
---|
| 1729 | The variant contains a QLocale object specifying the language of a
|
---|
| 1730 | certain part of the preedit string. There should be at most one
|
---|
| 1731 | language set for every part of the preedit string. If several are
|
---|
| 1732 | specified for any character in the string the behavior is undefined.
|
---|
| 1733 |
|
---|
| 1734 | \value Ruby
|
---|
| 1735 | The ruby text for a part of the preedit string. There should be at
|
---|
| 1736 | most one ruby text set for every part of the preedit string. If
|
---|
| 1737 | several are specified for any character in the string the behaviour
|
---|
| 1738 | is undefined.
|
---|
| 1739 |
|
---|
[561] | 1740 | \value Selection
|
---|
| 1741 | If set, the edit cursor should be moved to the specified position
|
---|
| 1742 | in the editor text contents. In contrast with \c Cursor, this
|
---|
| 1743 | attribute does not work on the preedit text, but on the surrounding
|
---|
| 1744 | text. The cursor will be moved after the commit string has been
|
---|
| 1745 | committed, and the preedit string will be located at the new edit
|
---|
| 1746 | position.
|
---|
| 1747 | The start position specifies the new position and the length
|
---|
| 1748 | variable can be used to set a selection starting from that point.
|
---|
| 1749 | The value is unused.
|
---|
| 1750 |
|
---|
[2] | 1751 | \sa Attribute
|
---|
| 1752 | */
|
---|
| 1753 |
|
---|
| 1754 | /*!
|
---|
| 1755 | \class QInputMethodEvent::Attribute
|
---|
| 1756 | \brief The QInputMethodEvent::Attribute class stores an input method attribute.
|
---|
| 1757 | */
|
---|
| 1758 |
|
---|
| 1759 | /*!
|
---|
| 1760 | \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
|
---|
| 1761 |
|
---|
| 1762 | Constructs an input method attribute. \a type specifies the type
|
---|
| 1763 | of attribute, \a start and \a length the position of the
|
---|
| 1764 | attribute, and \a value the value of the attribute.
|
---|
| 1765 | */
|
---|
| 1766 |
|
---|
| 1767 | /*!
|
---|
| 1768 | Constructs an event of type QEvent::InputMethod. The
|
---|
| 1769 | attributes(), preeditString(), commitString(), replacementStart(),
|
---|
| 1770 | and replacementLength() are initialized to default values.
|
---|
| 1771 |
|
---|
| 1772 | \sa setCommitString()
|
---|
| 1773 | */
|
---|
| 1774 | QInputMethodEvent::QInputMethodEvent()
|
---|
| 1775 | : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
|
---|
| 1776 | {
|
---|
| 1777 | }
|
---|
| 1778 |
|
---|
| 1779 | /*!
|
---|
| 1780 | Construcs an event of type QEvent::InputMethod. The
|
---|
| 1781 | preedit text is set to \a preeditText, the attributes to
|
---|
| 1782 | \a attributes.
|
---|
| 1783 |
|
---|
| 1784 | The commitString(), replacementStart(), and replacementLength()
|
---|
| 1785 | values can be set using setCommitString().
|
---|
| 1786 |
|
---|
| 1787 | \sa preeditString(), attributes()
|
---|
| 1788 | */
|
---|
| 1789 | QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
|
---|
| 1790 | : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
|
---|
| 1791 | replace_from(0), replace_length(0)
|
---|
| 1792 | {
|
---|
| 1793 | }
|
---|
| 1794 |
|
---|
| 1795 | /*!
|
---|
| 1796 | Constructs a copy of \a other.
|
---|
| 1797 | */
|
---|
| 1798 | QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
|
---|
| 1799 | : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
|
---|
| 1800 | commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
|
---|
| 1801 | {
|
---|
| 1802 | }
|
---|
| 1803 |
|
---|
| 1804 | /*!
|
---|
| 1805 | Sets the commit string to \a commitString.
|
---|
| 1806 |
|
---|
| 1807 | The commit string is the text that should get added to (or
|
---|
| 1808 | replace parts of) the text of the editor widget. It usually is a
|
---|
| 1809 | result of the input operations and has to be inserted to the
|
---|
| 1810 | widgets text directly before the preedit string.
|
---|
| 1811 |
|
---|
| 1812 | If the commit string should replace parts of the of the text in
|
---|
| 1813 | the editor, \a replaceLength specifies the number of
|
---|
| 1814 | characters to be replaced. \a replaceFrom specifies the position
|
---|
| 1815 | at which characters are to be replaced relative from the start of
|
---|
| 1816 | the preedit string.
|
---|
| 1817 |
|
---|
| 1818 | \sa commitString(), replacementStart(), replacementLength()
|
---|
| 1819 | */
|
---|
| 1820 | void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
|
---|
| 1821 | {
|
---|
| 1822 | commit = commitString;
|
---|
| 1823 | replace_from = replaceFrom;
|
---|
| 1824 | replace_length = replaceLength;
|
---|
| 1825 | }
|
---|
| 1826 |
|
---|
| 1827 | /*!
|
---|
| 1828 | \fn const QList<Attribute> &QInputMethodEvent::attributes() const
|
---|
| 1829 |
|
---|
| 1830 | Returns the list of attributes passed to the QInputMethodEvent
|
---|
| 1831 | constructor. The attributes control the visual appearance of the
|
---|
| 1832 | preedit string (the visual appearance of text outside the preedit
|
---|
| 1833 | string is controlled by the widget only).
|
---|
| 1834 |
|
---|
| 1835 | \sa preeditString(), Attribute
|
---|
| 1836 | */
|
---|
| 1837 |
|
---|
| 1838 | /*!
|
---|
| 1839 | \fn const QString &QInputMethodEvent::preeditString() const
|
---|
| 1840 |
|
---|
| 1841 | Returns the preedit text, i.e. the text before the user started
|
---|
| 1842 | editing it.
|
---|
| 1843 |
|
---|
| 1844 | \sa commitString(), attributes()
|
---|
| 1845 | */
|
---|
| 1846 |
|
---|
| 1847 | /*!
|
---|
| 1848 | \fn const QString &QInputMethodEvent::commitString() const
|
---|
| 1849 |
|
---|
| 1850 | Returns the text that should get added to (or replace parts of)
|
---|
| 1851 | the text of the editor widget. It usually is a result of the
|
---|
| 1852 | input operations and has to be inserted to the widgets text
|
---|
| 1853 | directly before the preedit string.
|
---|
| 1854 |
|
---|
| 1855 | \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
|
---|
| 1856 | */
|
---|
| 1857 |
|
---|
| 1858 | /*!
|
---|
| 1859 | \fn int QInputMethodEvent::replacementStart() const
|
---|
| 1860 |
|
---|
| 1861 | Returns the position at which characters are to be replaced relative
|
---|
| 1862 | from the start of the preedit string.
|
---|
| 1863 |
|
---|
| 1864 | \sa replacementLength(), setCommitString()
|
---|
| 1865 | */
|
---|
| 1866 |
|
---|
| 1867 | /*!
|
---|
| 1868 | \fn int QInputMethodEvent::replacementLength() const
|
---|
| 1869 |
|
---|
| 1870 | Returns the number of characters to be replaced in the preedit
|
---|
| 1871 | string.
|
---|
| 1872 |
|
---|
| 1873 | \sa replacementStart(), setCommitString()
|
---|
| 1874 | */
|
---|
| 1875 |
|
---|
| 1876 | #ifndef QT_NO_TABLETEVENT
|
---|
| 1877 |
|
---|
| 1878 | /*!
|
---|
| 1879 | \class QTabletEvent
|
---|
| 1880 | \brief The QTabletEvent class contains parameters that describe a Tablet event.
|
---|
| 1881 |
|
---|
| 1882 | \ingroup events
|
---|
| 1883 |
|
---|
| 1884 | Tablet Events are generated from a Wacom tablet. Most of the time you will
|
---|
| 1885 | want to deal with events from the tablet as if they were events from a
|
---|
| 1886 | mouse; for example, you would retrieve the cursor position with x(), y(),
|
---|
| 1887 | pos(), globalX(), globalY(), and globalPos(). In some situations you may
|
---|
| 1888 | wish to retrieve the extra information provided by the tablet device
|
---|
| 1889 | driver; for example, you might want to do subpixeling with higher
|
---|
| 1890 | resolution coordinates or you may want to adjust color brightness based on
|
---|
| 1891 | pressure. QTabletEvent allows you to read the pressure(), the xTilt(), and
|
---|
| 1892 | yTilt(), as well as the type of device being used with device() (see
|
---|
| 1893 | \l{TabletDevice}). It can also give you the minimum and maximum values for
|
---|
| 1894 | each device's pressure and high resolution coordinates.
|
---|
| 1895 |
|
---|
| 1896 | A tablet event contains a special accept flag that indicates whether the
|
---|
| 1897 | receiver wants the event. You should call QTabletEvent::accept() if you
|
---|
| 1898 | handle the tablet event; otherwise it will be sent to the parent widget.
|
---|
| 1899 | The exception are TabletEnterProximity and TabletLeaveProximity events,
|
---|
| 1900 | these are only sent to QApplication and don't check whether or not they are
|
---|
| 1901 | accepted.
|
---|
| 1902 |
|
---|
| 1903 | The QWidget::setEnabled() function can be used to enable or
|
---|
| 1904 | disable mouse and keyboard events for a widget.
|
---|
| 1905 |
|
---|
| 1906 | The event handler QWidget::tabletEvent() receives all three types of
|
---|
| 1907 | tablet events. Qt will first send a tabletEvent then, if it is not
|
---|
| 1908 | accepted, it will send a mouse event. This allows applications that
|
---|
| 1909 | don't utilize tablets to use a tablet like a mouse, while also
|
---|
| 1910 | enabling those who want to use both tablets and mouses differently.
|
---|
| 1911 |
|
---|
| 1912 | \section1 Notes for X11 Users
|
---|
| 1913 |
|
---|
| 1914 | Qt uses the following hard-coded names to identify tablet
|
---|
| 1915 | devices from the xorg.conf file on X11 (apart from IRIX):
|
---|
| 1916 | 'stylus', 'pen', and 'eraser'. If the devices have other names,
|
---|
| 1917 | they will not be picked up Qt.
|
---|
| 1918 | */
|
---|
| 1919 |
|
---|
| 1920 | /*!
|
---|
| 1921 | \enum QTabletEvent::TabletDevice
|
---|
| 1922 |
|
---|
| 1923 | This enum defines what type of device is generating the event.
|
---|
| 1924 |
|
---|
| 1925 | \value NoDevice No device, or an unknown device.
|
---|
| 1926 | \value Puck A Puck (a device that is similar to a flat mouse with
|
---|
| 1927 | a transparent circle with cross-hairs).
|
---|
| 1928 | \value Stylus A Stylus.
|
---|
| 1929 | \value Airbrush An airbrush
|
---|
| 1930 | \value FourDMouse A 4D Mouse.
|
---|
| 1931 | \value RotationStylus A special stylus that also knows about rotation
|
---|
| 1932 | (a 6D stylus). \since 4.1
|
---|
| 1933 | \omitvalue XFreeEraser
|
---|
| 1934 | */
|
---|
| 1935 |
|
---|
| 1936 | /*!
|
---|
| 1937 | \enum QTabletEvent::PointerType
|
---|
| 1938 |
|
---|
| 1939 | This enum defines what type of point is generating the event.
|
---|
| 1940 |
|
---|
| 1941 | \value UnknownPointer An unknown device.
|
---|
| 1942 | \value Pen Tip end of a stylus-like device (the narrow end of the pen).
|
---|
| 1943 | \value Cursor Any puck-like device.
|
---|
| 1944 | \value Eraser Eraser end of a stylus-like device (the broad end of the pen).
|
---|
| 1945 |
|
---|
| 1946 | \sa pointerType()
|
---|
| 1947 | */
|
---|
| 1948 |
|
---|
| 1949 | /*!
|
---|
| 1950 | Construct a tablet event of the given \a type.
|
---|
| 1951 |
|
---|
| 1952 | The \a pos parameter indicates where the event occurred in the
|
---|
| 1953 | widget; \a globalPos is the corresponding position in absolute
|
---|
| 1954 | coordinates. The \a hiResGlobalPos contains a high resolution
|
---|
| 1955 | measurement of the position.
|
---|
| 1956 |
|
---|
| 1957 | \a pressure contains the pressure exerted on the \a device.
|
---|
| 1958 |
|
---|
| 1959 | \a pointerType describes the type of pen that is being used.
|
---|
| 1960 |
|
---|
| 1961 | \a xTilt and \a yTilt contain the device's degree of tilt from the
|
---|
| 1962 | x and y axes respectively.
|
---|
| 1963 |
|
---|
| 1964 | \a keyState specifies which keyboard modifiers are pressed (e.g.,
|
---|
| 1965 | \key{Ctrl}).
|
---|
| 1966 |
|
---|
| 1967 | The \a uniqueID parameter contains the unique ID for the current device.
|
---|
| 1968 |
|
---|
| 1969 | The \a z parameter contains the coordinate of the device on the tablet, this
|
---|
| 1970 | is usually given by a wheel on 4D mouse. If the device does not support a
|
---|
| 1971 | Z-axis, pass zero here.
|
---|
| 1972 |
|
---|
[846] | 1973 | The \a tangentialPressure parameter contins the tangential pressure of an air
|
---|
[2] | 1974 | brush. If the device does not support tangential pressure, pass 0 here.
|
---|
| 1975 |
|
---|
| 1976 | \a rotation contains the device's rotation in degrees. 4D mice support
|
---|
| 1977 | rotation. If the device does not support rotation, pass 0 here.
|
---|
| 1978 |
|
---|
| 1979 | \sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z()
|
---|
| 1980 | */
|
---|
| 1981 |
|
---|
| 1982 | QTabletEvent::QTabletEvent(Type type, const QPoint &pos, const QPoint &globalPos,
|
---|
| 1983 | const QPointF &hiResGlobalPos, int device, int pointerType,
|
---|
| 1984 | qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
|
---|
| 1985 | qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
|
---|
| 1986 | : QInputEvent(type, keyState),
|
---|
| 1987 | mPos(pos),
|
---|
| 1988 | mGPos(globalPos),
|
---|
| 1989 | mHiResGlobalPos(hiResGlobalPos),
|
---|
| 1990 | mDev(device),
|
---|
| 1991 | mPointerType(pointerType),
|
---|
| 1992 | mXT(xTilt),
|
---|
| 1993 | mYT(yTilt),
|
---|
| 1994 | mZ(z),
|
---|
| 1995 | mPress(pressure),
|
---|
| 1996 | mTangential(tangentialPressure),
|
---|
| 1997 | mRot(rotation),
|
---|
| 1998 | mUnique(uniqueID),
|
---|
| 1999 | mExtra(0)
|
---|
| 2000 | {
|
---|
| 2001 | }
|
---|
| 2002 |
|
---|
| 2003 | /*!
|
---|
| 2004 | \internal
|
---|
| 2005 | */
|
---|
| 2006 | QTabletEvent::~QTabletEvent()
|
---|
| 2007 | {
|
---|
| 2008 | }
|
---|
| 2009 |
|
---|
| 2010 | /*!
|
---|
| 2011 | \fn TabletDevices QTabletEvent::device() const
|
---|
| 2012 |
|
---|
| 2013 | Returns the type of device that generated the event.
|
---|
| 2014 |
|
---|
| 2015 | \sa TabletDevice
|
---|
| 2016 | */
|
---|
| 2017 |
|
---|
| 2018 | /*!
|
---|
| 2019 | \fn PointerType QTabletEvent::pointerType() const
|
---|
| 2020 |
|
---|
| 2021 | Returns the type of point that generated the event.
|
---|
| 2022 | */
|
---|
| 2023 |
|
---|
| 2024 | /*!
|
---|
| 2025 | \fn qreal QTabletEvent::tangentialPressure() const
|
---|
| 2026 |
|
---|
| 2027 | Returns the tangential pressure for the device. This is typically given by a finger
|
---|
| 2028 | wheel on an airbrush tool. The range is from -1.0 to 1.0. 0.0 indicates a
|
---|
| 2029 | neutral position. Current airbrushes can only move in the positive
|
---|
| 2030 | direction from the neutrual position. If the device does not support
|
---|
| 2031 | tangential pressure, this value is always 0.0.
|
---|
| 2032 |
|
---|
| 2033 | \sa pressure()
|
---|
| 2034 | */
|
---|
| 2035 |
|
---|
| 2036 | /*!
|
---|
| 2037 | \fn qreal QTabletEvent::rotation() const
|
---|
| 2038 |
|
---|
| 2039 | Returns the rotation of the current device in degress. This is usually
|
---|
| 2040 | given by a 4D Mouse. If the device doesn't support rotation this value is
|
---|
| 2041 | always 0.0.
|
---|
| 2042 |
|
---|
| 2043 | */
|
---|
| 2044 |
|
---|
| 2045 | /*!
|
---|
| 2046 | \fn qreal QTabletEvent::pressure() const
|
---|
| 2047 |
|
---|
| 2048 | Returns the pressure for the device. 0.0 indicates that the stylus is not
|
---|
| 2049 | on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
|
---|
| 2050 |
|
---|
| 2051 | \sa tangentialPressure()
|
---|
| 2052 | */
|
---|
| 2053 |
|
---|
| 2054 | /*!
|
---|
| 2055 | \fn int QTabletEvent::xTilt() const
|
---|
| 2056 |
|
---|
| 2057 | Returns the angle between the device (a pen, for example) and the
|
---|
| 2058 | perpendicular in the direction of the x axis.
|
---|
| 2059 | Positive values are towards the tablet's physical right. The angle
|
---|
| 2060 | is in the range -60 to +60 degrees.
|
---|
| 2061 |
|
---|
| 2062 | \img qtabletevent-tilt.png
|
---|
| 2063 |
|
---|
| 2064 | \sa yTilt()
|
---|
| 2065 | */
|
---|
| 2066 |
|
---|
| 2067 | /*!
|
---|
| 2068 | \fn int QTabletEvent::yTilt() const
|
---|
| 2069 |
|
---|
| 2070 | Returns the angle between the device (a pen, for example) and the
|
---|
| 2071 | perpendicular in the direction of the y axis.
|
---|
| 2072 | Positive values are towards the bottom of the tablet. The angle is
|
---|
| 2073 | within the range -60 to +60 degrees.
|
---|
| 2074 |
|
---|
| 2075 | \sa xTilt()
|
---|
| 2076 | */
|
---|
| 2077 |
|
---|
| 2078 | /*!
|
---|
| 2079 | \fn const QPoint &QTabletEvent::pos() const
|
---|
| 2080 |
|
---|
| 2081 | Returns the position of the device, relative to the widget that
|
---|
| 2082 | received the event.
|
---|
| 2083 |
|
---|
| 2084 | If you move widgets around in response to mouse events, use
|
---|
| 2085 | globalPos() instead of this function.
|
---|
| 2086 |
|
---|
| 2087 | \sa x() y() globalPos()
|
---|
| 2088 | */
|
---|
| 2089 |
|
---|
| 2090 | /*!
|
---|
| 2091 | \fn int QTabletEvent::x() const
|
---|
| 2092 |
|
---|
| 2093 | Returns the x position of the device, relative to the widget that
|
---|
| 2094 | received the event.
|
---|
| 2095 |
|
---|
| 2096 | \sa y() pos()
|
---|
| 2097 | */
|
---|
| 2098 |
|
---|
| 2099 | /*!
|
---|
| 2100 | \fn int QTabletEvent::y() const
|
---|
| 2101 |
|
---|
| 2102 | Returns the y position of the device, relative to the widget that
|
---|
| 2103 | received the event.
|
---|
| 2104 |
|
---|
| 2105 | \sa x() pos()
|
---|
| 2106 | */
|
---|
| 2107 |
|
---|
| 2108 | /*!
|
---|
| 2109 | \fn int QTabletEvent::z() const
|
---|
| 2110 |
|
---|
| 2111 | Returns the z position of the device. Typically this is represented by a
|
---|
| 2112 | wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
|
---|
| 2113 | always zero. This is \bold not the same as pressure.
|
---|
| 2114 |
|
---|
| 2115 | \sa pressure()
|
---|
| 2116 | */
|
---|
| 2117 |
|
---|
| 2118 | /*!
|
---|
| 2119 | \fn const QPoint &QTabletEvent::globalPos() const
|
---|
| 2120 |
|
---|
| 2121 | Returns the global position of the device \e{at the time of the
|
---|
| 2122 | event}. This is important on asynchronous windows systems like X11;
|
---|
| 2123 | whenever you move your widgets around in response to mouse events,
|
---|
| 2124 | globalPos() can differ significantly from the current position
|
---|
| 2125 | QCursor::pos().
|
---|
| 2126 |
|
---|
| 2127 | \sa globalX() globalY() hiResGlobalPos()
|
---|
| 2128 | */
|
---|
| 2129 |
|
---|
| 2130 | /*!
|
---|
| 2131 | \fn int QTabletEvent::globalX() const
|
---|
| 2132 |
|
---|
| 2133 | Returns the global x position of the mouse pointer at the time of
|
---|
| 2134 | the event.
|
---|
| 2135 |
|
---|
| 2136 | \sa globalY() globalPos() hiResGlobalX()
|
---|
| 2137 | */
|
---|
| 2138 |
|
---|
| 2139 | /*!
|
---|
| 2140 | \fn int QTabletEvent::globalY() const
|
---|
| 2141 |
|
---|
| 2142 | Returns the global y position of the tablet device at the time of
|
---|
| 2143 | the event.
|
---|
| 2144 |
|
---|
| 2145 | \sa globalX() globalPos() hiResGlobalY()
|
---|
| 2146 | */
|
---|
| 2147 |
|
---|
| 2148 | /*!
|
---|
| 2149 | \fn qint64 QTabletEvent::uniqueId() const
|
---|
| 2150 |
|
---|
| 2151 | Returns a unique ID for the current device, making it possible
|
---|
| 2152 | to differentiate between multiple devices being used at the same
|
---|
| 2153 | time on the tablet.
|
---|
| 2154 |
|
---|
| 2155 | Support of this feature is dependent on the tablet.
|
---|
| 2156 |
|
---|
| 2157 | Values for the same device may vary from OS to OS.
|
---|
| 2158 |
|
---|
| 2159 | Later versions of the Wacom driver for Linux will now report
|
---|
| 2160 | the ID information. If you have a tablet that supports unique ID
|
---|
| 2161 | and are not getting the information on Linux, consider upgrading
|
---|
| 2162 | your driver.
|
---|
| 2163 |
|
---|
| 2164 | As of Qt 4.2, the unique ID is the same regardless of the orientation
|
---|
| 2165 | of the pen. Earlier versions would report a different value when using
|
---|
| 2166 | the eraser-end versus the pen-end of the stylus on some OS's.
|
---|
| 2167 |
|
---|
| 2168 | \sa pointerType()
|
---|
| 2169 | */
|
---|
| 2170 |
|
---|
| 2171 | /*!
|
---|
| 2172 | \fn const QPointF &QTabletEvent::hiResGlobalPos() const
|
---|
| 2173 |
|
---|
| 2174 | The high precision coordinates delivered from the tablet expressed.
|
---|
| 2175 | Sub pixeling information is in the fractional part of the QPointF.
|
---|
| 2176 |
|
---|
| 2177 | \sa globalPos() hiResGlobalX() hiResGlobalY()
|
---|
| 2178 | */
|
---|
| 2179 |
|
---|
| 2180 | /*!
|
---|
| 2181 | \fn qreal &QTabletEvent::hiResGlobalX() const
|
---|
| 2182 |
|
---|
| 2183 | The high precision x position of the tablet device.
|
---|
| 2184 | */
|
---|
| 2185 |
|
---|
| 2186 | /*!
|
---|
| 2187 | \fn qreal &QTabletEvent::hiResGlobalY() const
|
---|
| 2188 |
|
---|
| 2189 | The high precision y position of the tablet device.
|
---|
| 2190 | */
|
---|
| 2191 |
|
---|
| 2192 | #endif // QT_NO_TABLETEVENT
|
---|
| 2193 |
|
---|
| 2194 | #ifndef QT_NO_DRAGANDDROP
|
---|
| 2195 | /*!
|
---|
| 2196 | Creates a QDragMoveEvent of the required \a type indicating
|
---|
| 2197 | that the mouse is at position \a pos given within a widget.
|
---|
| 2198 |
|
---|
| 2199 | The mouse and keyboard states are specified by \a buttons and
|
---|
| 2200 | \a modifiers, and the \a actions describe the types of drag
|
---|
| 2201 | and drop operation that are possible.
|
---|
| 2202 | The drag data is passed as MIME-encoded information in \a data.
|
---|
| 2203 |
|
---|
| 2204 | \warning Do not attempt to create a QDragMoveEvent yourself.
|
---|
| 2205 | These objects rely on Qt's internal state.
|
---|
| 2206 | */
|
---|
| 2207 | QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
|
---|
| 2208 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
|
---|
| 2209 | : QDropEvent(pos, actions, data, buttons, modifiers, type)
|
---|
| 2210 | , rect(pos, QSize(1, 1))
|
---|
| 2211 | {}
|
---|
| 2212 |
|
---|
| 2213 | /*!
|
---|
| 2214 | Destroys the event.
|
---|
| 2215 | */
|
---|
| 2216 | QDragMoveEvent::~QDragMoveEvent()
|
---|
| 2217 | {
|
---|
| 2218 | }
|
---|
| 2219 |
|
---|
| 2220 | /*!
|
---|
| 2221 | \fn void QDragMoveEvent::accept(bool y)
|
---|
| 2222 |
|
---|
| 2223 | Calls setAccepted(\a y) instead.
|
---|
| 2224 | */
|
---|
| 2225 |
|
---|
| 2226 | /*!
|
---|
| 2227 | \fn void QDragMoveEvent::accept(const QRect &rectangle)
|
---|
| 2228 |
|
---|
| 2229 | The same as accept(), but also notifies that future moves will
|
---|
| 2230 | also be acceptable if they remain within the \a rectangle
|
---|
| 2231 | given on the widget. This can improve performance, but may
|
---|
| 2232 | also be ignored by the underlying system.
|
---|
| 2233 |
|
---|
| 2234 | If the rectangle is empty, drag move events will be sent
|
---|
| 2235 | continuously. This is useful if the source is scrolling in a
|
---|
| 2236 | timer event.
|
---|
| 2237 | */
|
---|
| 2238 |
|
---|
| 2239 | /*!
|
---|
| 2240 | \fn void QDragMoveEvent::accept()
|
---|
| 2241 |
|
---|
| 2242 | \overload
|
---|
| 2243 |
|
---|
| 2244 | Calls QDropEvent::accept().
|
---|
| 2245 | */
|
---|
| 2246 |
|
---|
| 2247 | /*!
|
---|
| 2248 | \fn void QDragMoveEvent::ignore()
|
---|
| 2249 |
|
---|
| 2250 | \overload
|
---|
| 2251 |
|
---|
| 2252 | Calls QDropEvent::ignore().
|
---|
| 2253 | */
|
---|
| 2254 |
|
---|
| 2255 | /*!
|
---|
| 2256 | \fn void QDragMoveEvent::ignore(const QRect &rectangle)
|
---|
| 2257 |
|
---|
| 2258 | The opposite of the accept(const QRect&) function.
|
---|
| 2259 | Moves within the \a rectangle are not acceptable, and will be
|
---|
| 2260 | ignored.
|
---|
| 2261 | */
|
---|
| 2262 |
|
---|
| 2263 | /*!
|
---|
| 2264 | \fn QRect QDragMoveEvent::answerRect() const
|
---|
| 2265 |
|
---|
| 2266 | Returns the rectangle in the widget where the drop will occur if accepted.
|
---|
| 2267 | You can use this information to restrict drops to certain places on the
|
---|
| 2268 | widget.
|
---|
| 2269 | */
|
---|
| 2270 |
|
---|
| 2271 |
|
---|
| 2272 | /*!
|
---|
| 2273 | \class QDropEvent
|
---|
| 2274 | \ingroup events
|
---|
| 2275 | \ingroup draganddrop
|
---|
| 2276 |
|
---|
| 2277 | \brief The QDropEvent class provides an event which is sent when a
|
---|
| 2278 | drag and drop action is completed.
|
---|
| 2279 |
|
---|
| 2280 | When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
|
---|
| 2281 | receive this event if it has accepted the most recent QDragEnterEvent or
|
---|
| 2282 | QDragMoveEvent sent to it.
|
---|
| 2283 |
|
---|
| 2284 | The drop event contains a proposed action, available from proposedAction(), for
|
---|
| 2285 | the widget to either accept or ignore. If the action can be handled by the
|
---|
| 2286 | widget, you should call the acceptProposedAction() function. Since the
|
---|
| 2287 | proposed action can be a combination of \l Qt::DropAction values, it may be
|
---|
| 2288 | useful to either select one of these values as a default action or ask
|
---|
| 2289 | the user to select their preferred action.
|
---|
| 2290 |
|
---|
| 2291 | If the proposed drop action is not suitable, perhaps because your custom
|
---|
| 2292 | widget does not support that action, you can replace it with any of the
|
---|
| 2293 | \l{possibleActions()}{possible drop actions} by calling setDropAction()
|
---|
| 2294 | with your preferred action. If you set a value that is not present in the
|
---|
| 2295 | bitwise OR combination of values returned by possibleActions(), the default
|
---|
| 2296 | copy action will be used. Once a replacement drop action has been set, call
|
---|
| 2297 | accept() instead of acceptProposedAction() to complete the drop operation.
|
---|
| 2298 |
|
---|
| 2299 | The mimeData() function provides the data dropped on the widget in a QMimeData
|
---|
| 2300 | object. This contains information about the MIME type of the data in addition to
|
---|
| 2301 | the data itself.
|
---|
| 2302 |
|
---|
| 2303 | \sa QMimeData, QDrag, {Drag and Drop}
|
---|
| 2304 | */
|
---|
| 2305 |
|
---|
| 2306 | /*!
|
---|
| 2307 | \fn const QMimeData *QDropEvent::mimeData() const
|
---|
| 2308 |
|
---|
| 2309 | Returns the data that was dropped on the widget and its associated MIME
|
---|
| 2310 | type information.
|
---|
| 2311 | */
|
---|
| 2312 |
|
---|
| 2313 | /*!
|
---|
| 2314 | Constructs a drop event of a certain \a type corresponding to a
|
---|
| 2315 | drop at the point specified by \a pos in the destination widget's
|
---|
| 2316 | coordinate system.
|
---|
| 2317 |
|
---|
| 2318 | The \a actions indicate which types of drag and drop operation can
|
---|
| 2319 | be performed, and the drag data is stored as MIME-encoded data in \a data.
|
---|
| 2320 |
|
---|
| 2321 | The states of the mouse buttons and keyboard modifiers at the time of
|
---|
| 2322 | the drop are specified by \a buttons and \a modifiers.
|
---|
| 2323 | */ // ### pos is in which coordinate system?
|
---|
| 2324 | QDropEvent::QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
|
---|
| 2325 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
|
---|
| 2326 | : QEvent(type), p(pos), mouseState(buttons),
|
---|
| 2327 | modState(modifiers), act(actions),
|
---|
| 2328 | mdata(data)
|
---|
| 2329 | {
|
---|
| 2330 | default_action = QDragManager::self()->defaultAction(act, modifiers);
|
---|
| 2331 | drop_action = default_action;
|
---|
| 2332 | ignore();
|
---|
| 2333 | }
|
---|
| 2334 |
|
---|
| 2335 | /*! \internal */
|
---|
| 2336 | QDropEvent::~QDropEvent()
|
---|
| 2337 | {
|
---|
| 2338 | }
|
---|
| 2339 |
|
---|
| 2340 | /*!
|
---|
| 2341 | \compat
|
---|
| 2342 | Returns a byte array containing the drag's data, in \a format.
|
---|
| 2343 |
|
---|
| 2344 | data() normally needs to get the data from the drag source, which
|
---|
| 2345 | is potentially very slow, so it's advisable to call this function
|
---|
| 2346 | only if you're sure that you will need the data in that
|
---|
| 2347 | particular \a format.
|
---|
| 2348 |
|
---|
| 2349 | The resulting data will have a size of 0 if the format was not
|
---|
| 2350 | available.
|
---|
| 2351 |
|
---|
| 2352 | \sa format() QByteArray::size()
|
---|
| 2353 | */
|
---|
| 2354 |
|
---|
| 2355 | QByteArray QDropEvent::encodedData(const char *format) const
|
---|
| 2356 | {
|
---|
| 2357 | return mdata->data(QLatin1String(format));
|
---|
| 2358 | }
|
---|
| 2359 |
|
---|
| 2360 | /*!
|
---|
| 2361 | \compat
|
---|
| 2362 | Returns a string describing one of the available data types for
|
---|
| 2363 | this drag. Common examples are "text/plain" and "image/gif".
|
---|
| 2364 | If \a n is less than zero or greater than the number of available
|
---|
| 2365 | data types, format() returns 0.
|
---|
| 2366 |
|
---|
| 2367 | This function is provided mainly for debugging. Most drop targets
|
---|
| 2368 | will use provides().
|
---|
| 2369 |
|
---|
| 2370 | \sa data() provides()
|
---|
| 2371 | */
|
---|
| 2372 |
|
---|
| 2373 | const char* QDropEvent::format(int n) const
|
---|
| 2374 | {
|
---|
| 2375 | if (fmts.isEmpty()) {
|
---|
| 2376 | QStringList formats = mdata->formats();
|
---|
| 2377 | for (int i = 0; i < formats.size(); ++i)
|
---|
| 2378 | fmts.append(formats.at(i).toLatin1());
|
---|
| 2379 | }
|
---|
| 2380 | if (n < 0 || n >= fmts.size())
|
---|
| 2381 | return 0;
|
---|
| 2382 | return fmts.at(n).constData();
|
---|
| 2383 | }
|
---|
| 2384 |
|
---|
| 2385 | /*!
|
---|
| 2386 | \compat
|
---|
| 2387 | Returns true if this event provides format \a mimeType; otherwise
|
---|
| 2388 | returns false.
|
---|
| 2389 |
|
---|
| 2390 | \sa data()
|
---|
| 2391 | */
|
---|
| 2392 |
|
---|
| 2393 | bool QDropEvent::provides(const char *mimeType) const
|
---|
| 2394 | {
|
---|
| 2395 | return mdata->formats().contains(QLatin1String(mimeType));
|
---|
| 2396 | }
|
---|
| 2397 |
|
---|
| 2398 | /*!
|
---|
| 2399 | If the source of the drag operation is a widget in this
|
---|
| 2400 | application, this function returns that source; otherwise it
|
---|
| 2401 | returns 0. The source of the operation is the first parameter to
|
---|
| 2402 | the QDrag object used instantiate the drag.
|
---|
| 2403 |
|
---|
| 2404 | This is useful if your widget needs special behavior when dragging
|
---|
| 2405 | to itself.
|
---|
| 2406 |
|
---|
| 2407 | \sa QDrag::QDrag()
|
---|
| 2408 | */
|
---|
| 2409 | QWidget* QDropEvent::source() const
|
---|
| 2410 | {
|
---|
| 2411 | QDragManager *manager = QDragManager::self();
|
---|
| 2412 | return manager ? manager->source() : 0;
|
---|
| 2413 | }
|
---|
| 2414 |
|
---|
| 2415 |
|
---|
| 2416 | void QDropEvent::setDropAction(Qt::DropAction action)
|
---|
| 2417 | {
|
---|
| 2418 | if (!(action & act) && action != Qt::IgnoreAction)
|
---|
| 2419 | action = default_action;
|
---|
| 2420 | drop_action = action;
|
---|
| 2421 | }
|
---|
| 2422 |
|
---|
| 2423 | /*!
|
---|
| 2424 | \fn const QPoint& QDropEvent::pos() const
|
---|
| 2425 |
|
---|
| 2426 | Returns the position where the drop was made.
|
---|
| 2427 | */
|
---|
| 2428 |
|
---|
| 2429 | /*!
|
---|
| 2430 | \fn Qt::MouseButtons QDropEvent::mouseButtons() const
|
---|
| 2431 |
|
---|
| 2432 | Returns the mouse buttons that are pressed..
|
---|
| 2433 | */
|
---|
| 2434 |
|
---|
| 2435 | /*!
|
---|
| 2436 | \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
|
---|
| 2437 |
|
---|
| 2438 | Returns the modifier keys that are pressed.
|
---|
| 2439 | */
|
---|
| 2440 |
|
---|
| 2441 | /*!
|
---|
| 2442 | \fn void QDropEvent::accept()
|
---|
| 2443 | \internal
|
---|
| 2444 | */
|
---|
| 2445 |
|
---|
| 2446 | /*!
|
---|
| 2447 | \fn void QDropEvent::accept(bool accept)
|
---|
| 2448 |
|
---|
| 2449 | Call setAccepted(\a accept) instead.
|
---|
| 2450 | */
|
---|
| 2451 |
|
---|
| 2452 | /*!
|
---|
| 2453 | \fn void QDropEvent::acceptAction(bool accept = true)
|
---|
| 2454 |
|
---|
| 2455 | Call this to indicate that the action described by action() is
|
---|
| 2456 | accepted (i.e. if \a accept is true, which is the default), not merely
|
---|
| 2457 | the default copy action. If you call acceptAction(true), there is
|
---|
| 2458 | no need to also call accept(true).
|
---|
| 2459 | */
|
---|
| 2460 |
|
---|
| 2461 | /*!
|
---|
| 2462 | \enum QDropEvent::Action
|
---|
| 2463 | \compat
|
---|
| 2464 |
|
---|
| 2465 | When a drag and drop action is completed, the target is expected
|
---|
| 2466 | to perform an action on the data provided by the source. This
|
---|
| 2467 | will be one of the following:
|
---|
| 2468 |
|
---|
| 2469 | \value Copy The default action. The source simply uses the data
|
---|
| 2470 | provided in the operation.
|
---|
| 2471 | \value Link The source should somehow create a link to the
|
---|
| 2472 | location specified by the data.
|
---|
| 2473 | \value Move The source should somehow move the object from the
|
---|
| 2474 | location specified by the data to a new location.
|
---|
| 2475 | \value Private The target has special knowledge of the MIME type,
|
---|
| 2476 | which the source should respond to in a similar way to
|
---|
| 2477 | a Copy.
|
---|
| 2478 | \value UserAction The source and target can co-operate using
|
---|
| 2479 | special actions. This feature is not currently
|
---|
| 2480 | supported.
|
---|
| 2481 |
|
---|
| 2482 | The Link and Move actions only makes sense if the data is a
|
---|
| 2483 | reference, for example, text/uri-list file lists (see QUriDrag).
|
---|
| 2484 | */
|
---|
| 2485 |
|
---|
| 2486 | /*!
|
---|
| 2487 | \fn void QDropEvent::setDropAction(Qt::DropAction action)
|
---|
| 2488 |
|
---|
| 2489 | Sets the \a action to be performed on the data by the target.
|
---|
| 2490 | Use this to override the \l{proposedAction()}{proposed action}
|
---|
| 2491 | with one of the \l{possibleActions()}{possible actions}.
|
---|
| 2492 |
|
---|
| 2493 | If you set a drop action that is not one of the possible actions, the
|
---|
| 2494 | drag and drop operation will default to a copy operation.
|
---|
| 2495 |
|
---|
| 2496 | Once you have supplied a replacement drop action, call accept()
|
---|
| 2497 | instead of acceptProposedAction().
|
---|
| 2498 |
|
---|
| 2499 | \sa dropAction()
|
---|
| 2500 | */
|
---|
| 2501 |
|
---|
| 2502 | /*!
|
---|
| 2503 | \fn Qt::DropAction QDropEvent::dropAction() const
|
---|
| 2504 |
|
---|
| 2505 | Returns the action to be performed on the data by the target. This may be
|
---|
| 2506 | different from the action supplied in proposedAction() if you have called
|
---|
| 2507 | setDropAction() to explicitly choose a drop action.
|
---|
| 2508 |
|
---|
| 2509 | \sa setDropAction()
|
---|
| 2510 | */
|
---|
| 2511 |
|
---|
| 2512 | /*!
|
---|
| 2513 | \fn Qt::DropActions QDropEvent::possibleActions() const
|
---|
| 2514 |
|
---|
| 2515 | Returns an OR-combination of possible drop actions.
|
---|
| 2516 |
|
---|
| 2517 | \sa dropAction()
|
---|
| 2518 | */
|
---|
| 2519 |
|
---|
| 2520 | /*!
|
---|
| 2521 | \fn Qt::DropAction QDropEvent::proposedAction() const
|
---|
| 2522 |
|
---|
| 2523 | Returns the proposed drop action.
|
---|
| 2524 |
|
---|
| 2525 | \sa dropAction()
|
---|
| 2526 | */
|
---|
| 2527 |
|
---|
| 2528 | /*!
|
---|
| 2529 | \fn void QDropEvent::acceptProposedAction()
|
---|
| 2530 |
|
---|
| 2531 | Sets the drop action to be the proposed action.
|
---|
| 2532 |
|
---|
| 2533 | \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
|
---|
| 2534 | */
|
---|
| 2535 |
|
---|
| 2536 | #ifdef QT3_SUPPORT
|
---|
| 2537 | /*!
|
---|
| 2538 | Use dropAction() instead.
|
---|
| 2539 |
|
---|
| 2540 | The table below shows the correspondance between the return type
|
---|
| 2541 | of action() and the return type of dropAction().
|
---|
| 2542 |
|
---|
| 2543 | \table
|
---|
| 2544 | \header \i Old enum value \i New enum value
|
---|
| 2545 | \row \i QDropEvent::Copy \i Qt::CopyAction
|
---|
| 2546 | \row \i QDropEvent::Move \i Qt::MoveAction
|
---|
| 2547 | \row \i QDropEvent::Link \i Qt::LinkAction
|
---|
| 2548 | \row \i other \i Qt::CopyAction
|
---|
| 2549 | \endtable
|
---|
| 2550 | */
|
---|
| 2551 |
|
---|
| 2552 | QT3_SUPPORT QDropEvent::Action QDropEvent::action() const
|
---|
| 2553 | {
|
---|
| 2554 | switch(drop_action) {
|
---|
| 2555 | case Qt::CopyAction:
|
---|
| 2556 | return Copy;
|
---|
| 2557 | case Qt::MoveAction:
|
---|
| 2558 | return Move;
|
---|
| 2559 | case Qt::LinkAction:
|
---|
| 2560 | return Link;
|
---|
| 2561 | default:
|
---|
| 2562 | return Copy;
|
---|
| 2563 | }
|
---|
| 2564 | }
|
---|
| 2565 | #endif
|
---|
| 2566 |
|
---|
| 2567 | /*!
|
---|
| 2568 | \fn void QDropEvent::setPoint(const QPoint &point)
|
---|
| 2569 | \compat
|
---|
| 2570 |
|
---|
| 2571 | Sets the drop to happen at the given \a point. You do not normally
|
---|
| 2572 | need to use this as it will be set internally before your widget
|
---|
| 2573 | receives the drop event.
|
---|
| 2574 | */ // ### here too - what coordinate system?
|
---|
| 2575 |
|
---|
| 2576 |
|
---|
| 2577 | /*!
|
---|
| 2578 | \class QDragEnterEvent
|
---|
| 2579 | \brief The QDragEnterEvent class provides an event which is sent
|
---|
| 2580 | to a widget when a drag and drop action enters it.
|
---|
| 2581 |
|
---|
| 2582 | \ingroup events
|
---|
| 2583 | \ingroup draganddrop
|
---|
| 2584 |
|
---|
| 2585 | A widget must accept this event in order to receive the \l
|
---|
| 2586 | {QDragMoveEvent}{drag move events} that are sent while the drag
|
---|
| 2587 | and drop action is in progress. The drag enter event is always
|
---|
| 2588 | immediately followed by a drag move event.
|
---|
| 2589 |
|
---|
| 2590 | QDragEnterEvent inherits most of its functionality from
|
---|
| 2591 | QDragMoveEvent, which in turn inherits most of its functionality
|
---|
| 2592 | from QDropEvent.
|
---|
| 2593 |
|
---|
| 2594 | \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
|
---|
| 2595 | */
|
---|
| 2596 |
|
---|
| 2597 | /*!
|
---|
| 2598 | Constructs a QDragEnterEvent that represents a drag entering a
|
---|
| 2599 | widget at the given \a point with mouse and keyboard states specified by
|
---|
| 2600 | \a buttons and \a modifiers.
|
---|
| 2601 |
|
---|
| 2602 | The drag data is passed as MIME-encoded information in \a data, and the
|
---|
| 2603 | specified \a actions describe the possible types of drag and drop
|
---|
| 2604 | operation that can be performed.
|
---|
| 2605 |
|
---|
| 2606 | \warning Do not create a QDragEnterEvent yourself since these
|
---|
| 2607 | objects rely on Qt's internal state.
|
---|
| 2608 | */
|
---|
| 2609 | QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
|
---|
| 2610 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
|
---|
| 2611 | : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
|
---|
| 2612 | {}
|
---|
| 2613 |
|
---|
| 2614 | /*! \internal
|
---|
| 2615 | */
|
---|
| 2616 | QDragEnterEvent::~QDragEnterEvent()
|
---|
| 2617 | {
|
---|
| 2618 | }
|
---|
| 2619 |
|
---|
| 2620 | /*!
|
---|
| 2621 | Constructs a drag response event containing the \a accepted value,
|
---|
| 2622 | indicating whether the drag and drop operation was accepted by the
|
---|
| 2623 | recipient.
|
---|
| 2624 | */
|
---|
| 2625 | QDragResponseEvent::QDragResponseEvent(bool accepted)
|
---|
| 2626 | : QEvent(DragResponse), a(accepted)
|
---|
| 2627 | {}
|
---|
| 2628 |
|
---|
| 2629 | /*! \internal
|
---|
| 2630 | */
|
---|
| 2631 | QDragResponseEvent::~QDragResponseEvent()
|
---|
| 2632 | {
|
---|
| 2633 | }
|
---|
| 2634 |
|
---|
| 2635 | /*!
|
---|
| 2636 | \class QDragMoveEvent
|
---|
| 2637 | \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
|
---|
| 2638 |
|
---|
| 2639 | \ingroup events
|
---|
| 2640 | \ingroup draganddrop
|
---|
| 2641 |
|
---|
| 2642 | A widget will receive drag move events repeatedly while the drag
|
---|
| 2643 | is within its boundaries, if it accepts
|
---|
| 2644 | \l{QWidget::setAcceptDrops()}{drop events} and \l
|
---|
| 2645 | {QWidget::dragEnterEvent()}{enter events}. The widget should
|
---|
| 2646 | examine the event to see what kind of data it
|
---|
| 2647 | \l{QDragMoveEvent::provides()}{provides}, and call the accept()
|
---|
| 2648 | function to accept the drop if appropriate.
|
---|
| 2649 |
|
---|
| 2650 | The rectangle supplied by the answerRect() function can be used to restrict
|
---|
| 2651 | drops to certain parts of the widget. For example, we can check whether the
|
---|
| 2652 | rectangle intersects with the geometry of a certain child widget and only
|
---|
| 2653 | call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
|
---|
| 2654 | is the case.
|
---|
| 2655 |
|
---|
| 2656 | Note that this class inherits most of its functionality from
|
---|
| 2657 | QDropEvent.
|
---|
| 2658 |
|
---|
| 2659 | \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
|
---|
| 2660 | */
|
---|
| 2661 |
|
---|
| 2662 | /*!
|
---|
| 2663 | \class QDragLeaveEvent
|
---|
| 2664 | \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
|
---|
| 2665 |
|
---|
| 2666 | \ingroup events
|
---|
| 2667 | \ingroup draganddrop
|
---|
| 2668 |
|
---|
| 2669 | This event is always preceded by a QDragEnterEvent and a series
|
---|
| 2670 | of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
|
---|
| 2671 | instead.
|
---|
| 2672 |
|
---|
| 2673 | \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
|
---|
| 2674 | */
|
---|
| 2675 |
|
---|
| 2676 | /*!
|
---|
| 2677 | Constructs a QDragLeaveEvent.
|
---|
| 2678 |
|
---|
| 2679 | \warning Do not create a QDragLeaveEvent yourself since these
|
---|
| 2680 | objects rely on Qt's internal state.
|
---|
| 2681 | */
|
---|
| 2682 | QDragLeaveEvent::QDragLeaveEvent()
|
---|
| 2683 | : QEvent(DragLeave)
|
---|
| 2684 | {}
|
---|
| 2685 |
|
---|
| 2686 | /*! \internal
|
---|
| 2687 | */
|
---|
| 2688 | QDragLeaveEvent::~QDragLeaveEvent()
|
---|
| 2689 | {
|
---|
| 2690 | }
|
---|
| 2691 | #endif // QT_NO_DRAGANDDROP
|
---|
| 2692 |
|
---|
| 2693 | /*!
|
---|
| 2694 | \class QHelpEvent
|
---|
| 2695 | \brief The QHelpEvent class provides an event that is used to request helpful information
|
---|
| 2696 | about a particular point in a widget.
|
---|
| 2697 |
|
---|
| 2698 | \ingroup events
|
---|
| 2699 | \ingroup helpsystem
|
---|
| 2700 |
|
---|
| 2701 | This event can be intercepted in applications to provide tooltips
|
---|
| 2702 | or "What's This?" help for custom widgets. The type() can be
|
---|
| 2703 | either QEvent::ToolTip or QEvent::WhatsThis.
|
---|
| 2704 |
|
---|
| 2705 | \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
|
---|
| 2706 | */
|
---|
| 2707 |
|
---|
| 2708 | /*!
|
---|
| 2709 | Constructs a help event with the given \a type corresponding to the
|
---|
| 2710 | widget-relative position specified by \a pos and the global position
|
---|
| 2711 | specified by \a globalPos.
|
---|
| 2712 |
|
---|
| 2713 | \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
|
---|
| 2714 |
|
---|
| 2715 | \sa pos(), globalPos()
|
---|
| 2716 | */
|
---|
| 2717 | QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
|
---|
| 2718 | : QEvent(type), p(pos), gp(globalPos)
|
---|
| 2719 | {}
|
---|
| 2720 |
|
---|
| 2721 | /*!
|
---|
| 2722 | \fn int QHelpEvent::x() const
|
---|
| 2723 |
|
---|
| 2724 | Same as pos().x().
|
---|
| 2725 |
|
---|
| 2726 | \sa y(), pos(), globalPos()
|
---|
| 2727 | */
|
---|
| 2728 |
|
---|
| 2729 | /*!
|
---|
| 2730 | \fn int QHelpEvent::y() const
|
---|
| 2731 |
|
---|
| 2732 | Same as pos().y().
|
---|
| 2733 |
|
---|
| 2734 | \sa x(), pos(), globalPos()
|
---|
| 2735 | */
|
---|
| 2736 |
|
---|
| 2737 | /*!
|
---|
| 2738 | \fn int QHelpEvent::globalX() const
|
---|
| 2739 |
|
---|
| 2740 | Same as globalPos().x().
|
---|
| 2741 |
|
---|
| 2742 | \sa x(), globalY(), globalPos()
|
---|
| 2743 | */
|
---|
| 2744 |
|
---|
| 2745 | /*!
|
---|
| 2746 | \fn int QHelpEvent::globalY() const
|
---|
| 2747 |
|
---|
| 2748 | Same as globalPos().y().
|
---|
| 2749 |
|
---|
| 2750 | \sa y(), globalX(), globalPos()
|
---|
| 2751 | */
|
---|
| 2752 |
|
---|
| 2753 | /*!
|
---|
| 2754 | \fn const QPoint &QHelpEvent::pos() const
|
---|
| 2755 |
|
---|
| 2756 | Returns the mouse cursor position when the event was generated,
|
---|
| 2757 | relative to the widget to which the event is dispatched.
|
---|
| 2758 |
|
---|
| 2759 | \sa globalPos(), x(), y()
|
---|
| 2760 | */
|
---|
| 2761 |
|
---|
| 2762 | /*!
|
---|
| 2763 | \fn const QPoint &QHelpEvent::globalPos() const
|
---|
| 2764 |
|
---|
| 2765 | Returns the mouse cursor position when the event was generated
|
---|
| 2766 | in global coordinates.
|
---|
| 2767 |
|
---|
| 2768 | \sa pos(), globalX(), globalY()
|
---|
| 2769 | */
|
---|
| 2770 |
|
---|
| 2771 | /*! \internal
|
---|
| 2772 | */
|
---|
| 2773 | QHelpEvent::~QHelpEvent()
|
---|
| 2774 | {
|
---|
| 2775 | }
|
---|
| 2776 |
|
---|
| 2777 | #ifndef QT_NO_STATUSTIP
|
---|
| 2778 |
|
---|
| 2779 | /*!
|
---|
| 2780 | \class QStatusTipEvent
|
---|
| 2781 | \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
|
---|
| 2782 |
|
---|
| 2783 | \ingroup events
|
---|
| 2784 | \ingroup helpsystem
|
---|
| 2785 |
|
---|
| 2786 | Status tips can be set on a widget using the
|
---|
| 2787 | QWidget::setStatusTip() function. They are shown in the status
|
---|
| 2788 | bar when the mouse cursor enters the widget. For example:
|
---|
| 2789 |
|
---|
| 2790 | \table 100%
|
---|
| 2791 | \row
|
---|
| 2792 | \o
|
---|
| 2793 | \snippet doc/src/snippets/qstatustipevent/main.cpp 1
|
---|
| 2794 | \dots
|
---|
| 2795 | \snippet doc/src/snippets/qstatustipevent/main.cpp 3
|
---|
| 2796 | \o
|
---|
| 2797 | \image qstatustipevent-widget.png Widget with status tip.
|
---|
| 2798 | \endtable
|
---|
| 2799 |
|
---|
| 2800 | Status tips can also be set on actions using the
|
---|
| 2801 | QAction::setStatusTip() function:
|
---|
| 2802 |
|
---|
| 2803 | \table 100%
|
---|
| 2804 | \row
|
---|
| 2805 | \o
|
---|
| 2806 | \snippet doc/src/snippets/qstatustipevent/main.cpp 0
|
---|
| 2807 | \snippet doc/src/snippets/qstatustipevent/main.cpp 2
|
---|
| 2808 | \dots
|
---|
| 2809 | \snippet doc/src/snippets/qstatustipevent/main.cpp 3
|
---|
| 2810 | \o
|
---|
| 2811 | \image qstatustipevent-action.png Action with status tip.
|
---|
| 2812 | \endtable
|
---|
| 2813 |
|
---|
| 2814 | Finally, status tips are supported for the item view classes
|
---|
| 2815 | through the Qt::StatusTipRole enum value.
|
---|
| 2816 |
|
---|
| 2817 | \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
|
---|
| 2818 | */
|
---|
| 2819 |
|
---|
| 2820 | /*!
|
---|
| 2821 | Constructs a status tip event with the text specified by \a tip.
|
---|
| 2822 |
|
---|
| 2823 | \sa tip()
|
---|
| 2824 | */
|
---|
| 2825 | QStatusTipEvent::QStatusTipEvent(const QString &tip)
|
---|
| 2826 | : QEvent(StatusTip), s(tip)
|
---|
| 2827 | {}
|
---|
| 2828 |
|
---|
| 2829 | /*! \internal
|
---|
| 2830 | */
|
---|
| 2831 | QStatusTipEvent::~QStatusTipEvent()
|
---|
| 2832 | {
|
---|
| 2833 | }
|
---|
| 2834 |
|
---|
| 2835 | /*!
|
---|
| 2836 | \fn QString QStatusTipEvent::tip() const
|
---|
| 2837 |
|
---|
| 2838 | Returns the message to show in the status bar.
|
---|
| 2839 |
|
---|
| 2840 | \sa QStatusBar::showMessage()
|
---|
| 2841 | */
|
---|
| 2842 |
|
---|
| 2843 | #endif // QT_NO_STATUSTIP
|
---|
| 2844 |
|
---|
| 2845 | #ifndef QT_NO_WHATSTHIS
|
---|
| 2846 |
|
---|
| 2847 | /*!
|
---|
| 2848 | \class QWhatsThisClickedEvent
|
---|
| 2849 | \brief The QWhatsThisClickedEvent class provides an event that
|
---|
| 2850 | can be used to handle hyperlinks in a "What's This?" text.
|
---|
| 2851 |
|
---|
| 2852 | \ingroup events
|
---|
| 2853 | \ingroup helpsystem
|
---|
| 2854 |
|
---|
| 2855 | \sa QWhatsThis, QHelpEvent, QStatusTipEvent
|
---|
| 2856 | */
|
---|
| 2857 |
|
---|
| 2858 | /*!
|
---|
| 2859 | Constructs an event containing a URL specified by \a href when a link
|
---|
| 2860 | is clicked in a "What's This?" message.
|
---|
| 2861 |
|
---|
| 2862 | \sa href()
|
---|
| 2863 | */
|
---|
| 2864 | QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
|
---|
| 2865 | : QEvent(WhatsThisClicked), s(href)
|
---|
| 2866 | {}
|
---|
| 2867 |
|
---|
| 2868 | /*! \internal
|
---|
| 2869 | */
|
---|
| 2870 | QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
|
---|
| 2871 | {
|
---|
| 2872 | }
|
---|
| 2873 |
|
---|
| 2874 | /*!
|
---|
| 2875 | \fn QString QWhatsThisClickedEvent::href() const
|
---|
| 2876 |
|
---|
| 2877 | Returns the URL that was clicked by the user in the "What's
|
---|
| 2878 | This?" text.
|
---|
| 2879 | */
|
---|
| 2880 |
|
---|
| 2881 | #endif // QT_NO_WHATSTHIS
|
---|
| 2882 |
|
---|
| 2883 | #ifndef QT_NO_ACTION
|
---|
| 2884 |
|
---|
| 2885 | /*!
|
---|
| 2886 | \class QActionEvent
|
---|
| 2887 | \brief The QActionEvent class provides an event that is generated
|
---|
| 2888 | when a QAction is added, removed, or changed.
|
---|
| 2889 |
|
---|
| 2890 | \ingroup events
|
---|
| 2891 |
|
---|
| 2892 | Actions can be added to widgets using QWidget::addAction(). This
|
---|
| 2893 | generates an \l ActionAdded event, which you can handle to provide
|
---|
| 2894 | custom behavior. For example, QToolBar reimplements
|
---|
| 2895 | QWidget::actionEvent() to create \l{QToolButton}s for the
|
---|
| 2896 | actions.
|
---|
| 2897 |
|
---|
| 2898 | \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
|
---|
| 2899 | */
|
---|
| 2900 |
|
---|
| 2901 | /*!
|
---|
| 2902 | Constructs an action event. The \a type can be \l ActionChanged,
|
---|
| 2903 | \l ActionAdded, or \l ActionRemoved.
|
---|
| 2904 |
|
---|
| 2905 | \a action is the action that is changed, added, or removed. If \a
|
---|
| 2906 | type is ActionAdded, the action is to be inserted before the
|
---|
| 2907 | action \a before. If \a before is 0, the action is appended.
|
---|
| 2908 | */
|
---|
| 2909 | QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
|
---|
| 2910 | : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
|
---|
| 2911 | {}
|
---|
| 2912 |
|
---|
| 2913 | /*! \internal
|
---|
| 2914 | */
|
---|
| 2915 | QActionEvent::~QActionEvent()
|
---|
| 2916 | {
|
---|
| 2917 | }
|
---|
| 2918 |
|
---|
| 2919 | /*!
|
---|
| 2920 | \fn QAction *QActionEvent::action() const
|
---|
| 2921 |
|
---|
| 2922 | Returns the action that is changed, added, or removed.
|
---|
| 2923 |
|
---|
| 2924 | \sa before()
|
---|
| 2925 | */
|
---|
| 2926 |
|
---|
| 2927 | /*!
|
---|
| 2928 | \fn QAction *QActionEvent::before() const
|
---|
| 2929 |
|
---|
| 2930 | If type() is \l ActionAdded, returns the action that should
|
---|
| 2931 | appear before action(). If this function returns 0, the action
|
---|
| 2932 | should be appended to already existing actions on the same
|
---|
| 2933 | widget.
|
---|
| 2934 |
|
---|
| 2935 | \sa action(), QWidget::actions()
|
---|
| 2936 | */
|
---|
| 2937 |
|
---|
| 2938 | #endif // QT_NO_ACTION
|
---|
| 2939 |
|
---|
| 2940 | /*!
|
---|
| 2941 | \class QHideEvent
|
---|
| 2942 | \brief The QHideEvent class provides an event which is sent after a widget is hidden.
|
---|
| 2943 |
|
---|
| 2944 | \ingroup events
|
---|
| 2945 |
|
---|
| 2946 | This event is sent just before QWidget::hide() returns, and also
|
---|
| 2947 | when a top-level window has been hidden (iconified) by the user.
|
---|
| 2948 |
|
---|
| 2949 | If spontaneous() is true, the event originated outside the
|
---|
| 2950 | application. In this case, the user hid the window using the
|
---|
| 2951 | window manager controls, either by iconifying the window or by
|
---|
| 2952 | switching to another virtual desktop where the window isn't
|
---|
| 2953 | visible. The window will become hidden but not withdrawn. If the
|
---|
| 2954 | window was iconified, QWidget::isMinimized() returns true.
|
---|
| 2955 |
|
---|
| 2956 | \sa QShowEvent
|
---|
| 2957 | */
|
---|
| 2958 |
|
---|
| 2959 | /*!
|
---|
| 2960 | Constructs a QHideEvent.
|
---|
| 2961 | */
|
---|
| 2962 | QHideEvent::QHideEvent()
|
---|
| 2963 | : QEvent(Hide)
|
---|
| 2964 | {}
|
---|
| 2965 |
|
---|
| 2966 | /*! \internal
|
---|
| 2967 | */
|
---|
| 2968 | QHideEvent::~QHideEvent()
|
---|
| 2969 | {
|
---|
| 2970 | }
|
---|
| 2971 |
|
---|
| 2972 | /*!
|
---|
| 2973 | \class QShowEvent
|
---|
| 2974 | \brief The QShowEvent class provides an event that is sent when a widget is shown.
|
---|
| 2975 |
|
---|
| 2976 | \ingroup events
|
---|
| 2977 |
|
---|
| 2978 | There are two kinds of show events: show events caused by the
|
---|
| 2979 | window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
|
---|
| 2980 | show events are sent just after the window system shows the
|
---|
| 2981 | window; they are also sent when a top-level window is redisplayed
|
---|
| 2982 | after being iconified. Internal show events are delivered just
|
---|
| 2983 | before the widget becomes visible.
|
---|
| 2984 |
|
---|
| 2985 | \sa QHideEvent
|
---|
| 2986 | */
|
---|
| 2987 |
|
---|
| 2988 | /*!
|
---|
| 2989 | Constructs a QShowEvent.
|
---|
| 2990 | */
|
---|
| 2991 | QShowEvent::QShowEvent()
|
---|
| 2992 | : QEvent(Show)
|
---|
| 2993 | {}
|
---|
| 2994 |
|
---|
| 2995 | /*! \internal
|
---|
| 2996 | */
|
---|
| 2997 | QShowEvent::~QShowEvent()
|
---|
| 2998 | {
|
---|
| 2999 | }
|
---|
| 3000 |
|
---|
| 3001 | /*!
|
---|
| 3002 | \fn QByteArray QDropEvent::data(const char* f) const
|
---|
| 3003 |
|
---|
| 3004 | \obsolete
|
---|
| 3005 |
|
---|
| 3006 | The encoded data is in \a f.
|
---|
| 3007 | Use QDropEvent::encodedData().
|
---|
| 3008 | */
|
---|
| 3009 |
|
---|
| 3010 | /*!
|
---|
| 3011 | \class QFileOpenEvent
|
---|
| 3012 | \brief The QFileOpenEvent class provides an event that will be
|
---|
[561] | 3013 | sent when there is a request to open a file or a URL.
|
---|
[2] | 3014 |
|
---|
| 3015 | \ingroup events
|
---|
| 3016 |
|
---|
| 3017 | File open events will be sent to the QApplication::instance()
|
---|
[561] | 3018 | when the operating system requests that a file or URL should be opened.
|
---|
| 3019 | This is a high-level event that can be caused by different user actions
|
---|
[2] | 3020 | depending on the user's desktop environment; for example, double
|
---|
| 3021 | clicking on an file icon in the Finder on Mac OS X.
|
---|
| 3022 |
|
---|
| 3023 | This event is only used to notify the application of a request.
|
---|
| 3024 | It may be safely ignored.
|
---|
| 3025 |
|
---|
[561] | 3026 | \note This class is currently supported for Mac OS X only.
|
---|
[2] | 3027 | */
|
---|
| 3028 |
|
---|
| 3029 | /*!
|
---|
| 3030 | \internal
|
---|
| 3031 |
|
---|
| 3032 | Constructs a file open event for the given \a file.
|
---|
| 3033 | */
|
---|
| 3034 | QFileOpenEvent::QFileOpenEvent(const QString &file)
|
---|
| 3035 | : QEvent(FileOpen), f(file)
|
---|
[561] | 3036 | {
|
---|
| 3037 | d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(QUrl::fromLocalFile(file)));
|
---|
| 3038 | }
|
---|
[2] | 3039 |
|
---|
[561] | 3040 | /*!
|
---|
| 3041 | \internal
|
---|
| 3042 |
|
---|
| 3043 | Constructs a file open event for the given \a url.
|
---|
| 3044 | */
|
---|
| 3045 | QFileOpenEvent::QFileOpenEvent(const QUrl &url)
|
---|
| 3046 | : QEvent(FileOpen)
|
---|
| 3047 | {
|
---|
| 3048 | d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(url));
|
---|
| 3049 | f = url.toLocalFile();
|
---|
| 3050 | }
|
---|
| 3051 |
|
---|
[2] | 3052 | /*! \internal
|
---|
| 3053 | */
|
---|
| 3054 | QFileOpenEvent::~QFileOpenEvent()
|
---|
| 3055 | {
|
---|
[561] | 3056 | delete reinterpret_cast<QFileOpenEventPrivate *>(d);
|
---|
[2] | 3057 | }
|
---|
| 3058 |
|
---|
| 3059 | /*!
|
---|
| 3060 | \fn QString QFileOpenEvent::file() const
|
---|
| 3061 |
|
---|
| 3062 | Returns the file that is being opened.
|
---|
| 3063 | */
|
---|
| 3064 |
|
---|
[561] | 3065 | /*!
|
---|
| 3066 | \fn QUrl QFileOpenEvent::url() const
|
---|
| 3067 |
|
---|
| 3068 | Returns the url that is being opened.
|
---|
| 3069 |
|
---|
| 3070 | \since 4.6
|
---|
| 3071 | */
|
---|
| 3072 | QUrl QFileOpenEvent::url() const
|
---|
| 3073 | {
|
---|
| 3074 | return reinterpret_cast<const QFileOpenEventPrivate *>(d)->url;
|
---|
| 3075 | }
|
---|
| 3076 |
|
---|
[2] | 3077 | #ifndef QT_NO_TOOLBAR
|
---|
| 3078 | /*!
|
---|
| 3079 | \internal
|
---|
| 3080 | \class QToolBarChangeEvent
|
---|
| 3081 | \brief The QToolBarChangeEvent class provides an event that is
|
---|
| 3082 | sent whenever a the toolbar button is clicked on Mac OS X.
|
---|
| 3083 |
|
---|
| 3084 | \ingroup events
|
---|
| 3085 |
|
---|
| 3086 | The QToolBarChangeEvent is sent when the toolbar button is clicked. On Mac
|
---|
| 3087 | OS X, this is the long oblong button on the right side of the window
|
---|
| 3088 | title bar. The default implementation is to toggle the appearance (hidden or
|
---|
| 3089 | shown) of the associated toolbars for the window.
|
---|
| 3090 | */
|
---|
| 3091 |
|
---|
| 3092 | /*!
|
---|
| 3093 | \internal
|
---|
| 3094 |
|
---|
| 3095 | Construct a QToolBarChangeEvent given the current button state in \a state.
|
---|
| 3096 | */
|
---|
| 3097 | QToolBarChangeEvent::QToolBarChangeEvent(bool t)
|
---|
| 3098 | : QEvent(ToolBarChange), tog(t)
|
---|
| 3099 | {}
|
---|
| 3100 |
|
---|
| 3101 | /*! \internal
|
---|
| 3102 | */
|
---|
| 3103 | QToolBarChangeEvent::~QToolBarChangeEvent()
|
---|
| 3104 | {
|
---|
| 3105 | }
|
---|
| 3106 |
|
---|
| 3107 | /*!
|
---|
| 3108 | \fn bool QToolBarChangeEvent::toggle() const
|
---|
| 3109 | \internal
|
---|
| 3110 | */
|
---|
| 3111 |
|
---|
| 3112 | /*
|
---|
| 3113 | \fn Qt::ButtonState QToolBarChangeEvent::state() const
|
---|
| 3114 |
|
---|
| 3115 | Returns the keyboard modifier flags at the time of the event.
|
---|
| 3116 |
|
---|
| 3117 | The returned value is a selection of the following values,
|
---|
| 3118 | combined using the OR operator:
|
---|
| 3119 | Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
|
---|
| 3120 | */
|
---|
| 3121 |
|
---|
| 3122 | #endif // QT_NO_TOOLBAR
|
---|
| 3123 |
|
---|
| 3124 | #ifndef QT_NO_SHORTCUT
|
---|
| 3125 |
|
---|
| 3126 | /*!
|
---|
| 3127 | Constructs a shortcut event for the given \a key press,
|
---|
| 3128 | associated with the QShortcut ID \a id.
|
---|
| 3129 |
|
---|
| 3130 | \a ambiguous specifies whether there is more than one QShortcut
|
---|
| 3131 | for the same key sequence.
|
---|
| 3132 | */
|
---|
| 3133 | QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
|
---|
| 3134 | : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
|
---|
| 3135 | {
|
---|
| 3136 | }
|
---|
| 3137 |
|
---|
| 3138 | /*!
|
---|
| 3139 | Destroys the event object.
|
---|
| 3140 | */
|
---|
| 3141 | QShortcutEvent::~QShortcutEvent()
|
---|
| 3142 | {
|
---|
| 3143 | }
|
---|
| 3144 |
|
---|
| 3145 | #endif // QT_NO_SHORTCUT
|
---|
| 3146 |
|
---|
| 3147 | #ifndef QT_NO_DEBUG_STREAM
|
---|
| 3148 | QDebug operator<<(QDebug dbg, const QEvent *e) {
|
---|
| 3149 | #ifndef Q_BROKEN_DEBUG_STREAM
|
---|
| 3150 | // More useful event output could be added here
|
---|
| 3151 | if (!e)
|
---|
| 3152 | return dbg << "QEvent(this = 0x0)";
|
---|
| 3153 | const char *n = 0;
|
---|
| 3154 | switch (e->type()) {
|
---|
| 3155 | case QEvent::Timer:
|
---|
| 3156 | n = "Timer";
|
---|
| 3157 | break;
|
---|
| 3158 | case QEvent::MouseButtonPress:
|
---|
| 3159 | case QEvent::MouseMove:
|
---|
| 3160 | case QEvent::MouseButtonRelease:
|
---|
| 3161 | case QEvent::MouseButtonDblClick:
|
---|
| 3162 | {
|
---|
| 3163 | const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
|
---|
| 3164 | switch(me->type()) {
|
---|
| 3165 | case QEvent::MouseButtonPress:
|
---|
| 3166 | n = "MouseButtonPress";
|
---|
| 3167 | break;
|
---|
| 3168 | case QEvent::MouseMove:
|
---|
| 3169 | n = "MouseMove";
|
---|
| 3170 | break;
|
---|
| 3171 | case QEvent::MouseButtonRelease:
|
---|
| 3172 | n = "MouseButtonRelease";
|
---|
| 3173 | break;
|
---|
| 3174 | case QEvent::MouseButtonDblClick:
|
---|
| 3175 | default:
|
---|
| 3176 | n = "MouseButtonDblClick";
|
---|
| 3177 | break;
|
---|
| 3178 | }
|
---|
| 3179 | dbg.nospace() << "QMouseEvent(" << n
|
---|
| 3180 | << ", " << me->button()
|
---|
| 3181 | << ", " << hex << (int)me->buttons()
|
---|
| 3182 | << ", " << hex << (int)me->modifiers()
|
---|
[561] | 3183 | << ')';
|
---|
[2] | 3184 | }
|
---|
| 3185 | return dbg.space();
|
---|
| 3186 |
|
---|
| 3187 | #ifndef QT_NO_TOOLTIP
|
---|
| 3188 | case QEvent::ToolTip:
|
---|
| 3189 | n = "ToolTip";
|
---|
| 3190 | break;
|
---|
| 3191 | #endif
|
---|
| 3192 | case QEvent::WindowActivate:
|
---|
| 3193 | n = "WindowActivate";
|
---|
| 3194 | break;
|
---|
| 3195 | case QEvent::WindowDeactivate:
|
---|
| 3196 | n = "WindowDeactivate";
|
---|
| 3197 | break;
|
---|
| 3198 | case QEvent::ActivationChange:
|
---|
| 3199 | n = "ActivationChange";
|
---|
| 3200 | break;
|
---|
| 3201 | #ifndef QT_NO_WHEELEVENT
|
---|
| 3202 | case QEvent::Wheel:
|
---|
| 3203 | dbg.nospace() << "QWheelEvent(" << static_cast<const QWheelEvent *>(e)->delta()
|
---|
[561] | 3204 | << ')';
|
---|
[2] | 3205 | return dbg.space();
|
---|
| 3206 | #endif
|
---|
| 3207 | case QEvent::KeyPress:
|
---|
| 3208 | case QEvent::KeyRelease:
|
---|
| 3209 | case QEvent::ShortcutOverride:
|
---|
| 3210 | {
|
---|
| 3211 | const QKeyEvent *ke = static_cast<const QKeyEvent*>(e);
|
---|
| 3212 | switch(ke->type()) {
|
---|
| 3213 | case QEvent::ShortcutOverride:
|
---|
| 3214 | n = "ShortcutOverride";
|
---|
| 3215 | break;
|
---|
| 3216 | case QEvent::KeyRelease:
|
---|
| 3217 | n = "KeyRelease";
|
---|
| 3218 | break;
|
---|
| 3219 | case QEvent::KeyPress:
|
---|
| 3220 | default:
|
---|
| 3221 | n = "KeyPress";
|
---|
| 3222 | break;
|
---|
| 3223 | }
|
---|
| 3224 | dbg.nospace() << "QKeyEvent(" << n
|
---|
| 3225 | << ", " << hex << ke->key()
|
---|
| 3226 | << ", " << hex << (int)ke->modifiers()
|
---|
| 3227 | << ", \"" << ke->text()
|
---|
| 3228 | << "\", " << ke->isAutoRepeat()
|
---|
| 3229 | << ", " << ke->count()
|
---|
[561] | 3230 | << ')';
|
---|
[2] | 3231 | }
|
---|
| 3232 | return dbg.space();
|
---|
| 3233 | case QEvent::FocusIn:
|
---|
| 3234 | n = "FocusIn";
|
---|
| 3235 | break;
|
---|
| 3236 | case QEvent::FocusOut:
|
---|
| 3237 | n = "FocusOut";
|
---|
| 3238 | break;
|
---|
| 3239 | case QEvent::Enter:
|
---|
| 3240 | n = "Enter";
|
---|
| 3241 | break;
|
---|
| 3242 | case QEvent::Leave:
|
---|
| 3243 | n = "Leave";
|
---|
| 3244 | break;
|
---|
| 3245 | case QEvent::PaletteChange:
|
---|
| 3246 | n = "PaletteChange";
|
---|
| 3247 | break;
|
---|
| 3248 | case QEvent::PolishRequest:
|
---|
| 3249 | n = "PolishRequest";
|
---|
| 3250 | break;
|
---|
| 3251 | case QEvent::Polish:
|
---|
| 3252 | n = "Polish";
|
---|
| 3253 | break;
|
---|
| 3254 | case QEvent::UpdateRequest:
|
---|
| 3255 | n = "UpdateRequest";
|
---|
| 3256 | break;
|
---|
| 3257 | case QEvent::Paint:
|
---|
| 3258 | n = "Paint";
|
---|
| 3259 | break;
|
---|
| 3260 | case QEvent::Move:
|
---|
| 3261 | n = "Move";
|
---|
| 3262 | break;
|
---|
| 3263 | case QEvent::Resize:
|
---|
| 3264 | n = "Resize";
|
---|
| 3265 | break;
|
---|
| 3266 | case QEvent::Create:
|
---|
| 3267 | n = "Create";
|
---|
| 3268 | break;
|
---|
| 3269 | case QEvent::Destroy:
|
---|
| 3270 | n = "Destroy";
|
---|
| 3271 | break;
|
---|
| 3272 | case QEvent::Close:
|
---|
| 3273 | n = "Close";
|
---|
| 3274 | break;
|
---|
| 3275 | case QEvent::Quit:
|
---|
| 3276 | n = "Quit";
|
---|
| 3277 | break;
|
---|
| 3278 | case QEvent::FileOpen:
|
---|
| 3279 | n = "FileOpen";
|
---|
| 3280 | break;
|
---|
| 3281 | case QEvent::Show:
|
---|
| 3282 | n = "Show";
|
---|
| 3283 | break;
|
---|
| 3284 | case QEvent::ShowToParent:
|
---|
| 3285 | n = "ShowToParent";
|
---|
| 3286 | break;
|
---|
| 3287 | case QEvent::Hide:
|
---|
| 3288 | n = "Hide";
|
---|
| 3289 | break;
|
---|
| 3290 | case QEvent::HideToParent:
|
---|
| 3291 | n = "HideToParent";
|
---|
| 3292 | break;
|
---|
| 3293 | case QEvent::None:
|
---|
| 3294 | n = "None";
|
---|
| 3295 | break;
|
---|
| 3296 | case QEvent::ParentChange:
|
---|
| 3297 | n = "ParentChange";
|
---|
| 3298 | break;
|
---|
| 3299 | case QEvent::ParentAboutToChange:
|
---|
| 3300 | n = "ParentAboutToChange";
|
---|
| 3301 | break;
|
---|
| 3302 | case QEvent::HoverEnter:
|
---|
| 3303 | n = "HoverEnter";
|
---|
| 3304 | break;
|
---|
| 3305 | case QEvent::HoverMove:
|
---|
| 3306 | n = "HoverMove";
|
---|
| 3307 | break;
|
---|
| 3308 | case QEvent::HoverLeave:
|
---|
| 3309 | n = "HoverLeave";
|
---|
| 3310 | break;
|
---|
| 3311 | case QEvent::ZOrderChange:
|
---|
| 3312 | n = "ZOrderChange";
|
---|
| 3313 | break;
|
---|
| 3314 | case QEvent::StyleChange:
|
---|
| 3315 | n = "StyleChange";
|
---|
| 3316 | break;
|
---|
| 3317 | case QEvent::DragEnter:
|
---|
| 3318 | n = "DragEnter";
|
---|
| 3319 | break;
|
---|
| 3320 | case QEvent::DragMove:
|
---|
| 3321 | n = "DragMove";
|
---|
| 3322 | break;
|
---|
| 3323 | case QEvent::DragLeave:
|
---|
| 3324 | n = "DragLeave";
|
---|
| 3325 | break;
|
---|
| 3326 | case QEvent::Drop:
|
---|
| 3327 | n = "Drop";
|
---|
| 3328 | break;
|
---|
| 3329 | case QEvent::GraphicsSceneMouseMove:
|
---|
| 3330 | n = "GraphicsSceneMouseMove";
|
---|
| 3331 | break;
|
---|
| 3332 | case QEvent::GraphicsSceneMousePress:
|
---|
| 3333 | n = "GraphicsSceneMousePress";
|
---|
| 3334 | break;
|
---|
| 3335 | case QEvent::GraphicsSceneMouseRelease:
|
---|
| 3336 | n = "GraphicsSceneMouseRelease";
|
---|
| 3337 | break;
|
---|
| 3338 | case QEvent::GraphicsSceneMouseDoubleClick:
|
---|
| 3339 | n = "GraphicsSceneMouseDoubleClick";
|
---|
| 3340 | break;
|
---|
| 3341 | case QEvent::GraphicsSceneContextMenu:
|
---|
| 3342 | n = "GraphicsSceneContextMenu";
|
---|
| 3343 | break;
|
---|
| 3344 | case QEvent::GraphicsSceneHoverEnter:
|
---|
| 3345 | n = "GraphicsSceneHoverEnter";
|
---|
| 3346 | break;
|
---|
| 3347 | case QEvent::GraphicsSceneHoverMove:
|
---|
| 3348 | n = "GraphicsSceneHoverMove";
|
---|
| 3349 | break;
|
---|
| 3350 | case QEvent::GraphicsSceneHoverLeave:
|
---|
| 3351 | n = "GraphicsSceneHoverLeave";
|
---|
| 3352 | break;
|
---|
| 3353 | case QEvent::GraphicsSceneHelp:
|
---|
| 3354 | n = "GraphicsSceneHelp";
|
---|
| 3355 | break;
|
---|
| 3356 | case QEvent::GraphicsSceneDragEnter:
|
---|
| 3357 | n = "GraphicsSceneDragEnter";
|
---|
| 3358 | break;
|
---|
| 3359 | case QEvent::GraphicsSceneDragMove:
|
---|
| 3360 | n = "GraphicsSceneDragMove";
|
---|
| 3361 | break;
|
---|
| 3362 | case QEvent::GraphicsSceneDragLeave:
|
---|
| 3363 | n = "GraphicsSceneDragLeave";
|
---|
| 3364 | break;
|
---|
| 3365 | case QEvent::GraphicsSceneDrop:
|
---|
| 3366 | n = "GraphicsSceneDrop";
|
---|
| 3367 | break;
|
---|
| 3368 | case QEvent::GraphicsSceneWheel:
|
---|
| 3369 | n = "GraphicsSceneWheel";
|
---|
| 3370 | break;
|
---|
| 3371 | case QEvent::GraphicsSceneResize:
|
---|
| 3372 | n = "GraphicsSceneResize";
|
---|
| 3373 | break;
|
---|
| 3374 | case QEvent::GraphicsSceneMove:
|
---|
| 3375 | n = "GraphicsSceneMove";
|
---|
| 3376 | break;
|
---|
| 3377 | case QEvent::CursorChange:
|
---|
| 3378 | n = "CursorChange";
|
---|
| 3379 | break;
|
---|
| 3380 | case QEvent::ToolTipChange:
|
---|
| 3381 | n = "ToolTipChange";
|
---|
| 3382 | break;
|
---|
| 3383 | case QEvent::StatusTip:
|
---|
| 3384 | n = "StatusTip";
|
---|
| 3385 | break;
|
---|
| 3386 | case QEvent::WhatsThis:
|
---|
| 3387 | n = "WhatsThis";
|
---|
| 3388 | break;
|
---|
| 3389 | case QEvent::FontChange:
|
---|
| 3390 | n = "FontChange";
|
---|
| 3391 | break;
|
---|
| 3392 | case QEvent::Style:
|
---|
| 3393 | n = "Style";
|
---|
| 3394 | break;
|
---|
| 3395 | case QEvent::KeyboardLayoutChange:
|
---|
| 3396 | n = "KeyboardLayoutChange";
|
---|
| 3397 | break;
|
---|
| 3398 | case QEvent::DynamicPropertyChange:
|
---|
| 3399 | n = "DynamicPropertyChange";
|
---|
| 3400 | break;
|
---|
| 3401 | case QEvent::GrabMouse:
|
---|
| 3402 | n = "GrabMouse";
|
---|
| 3403 | break;
|
---|
| 3404 | case QEvent::UngrabMouse:
|
---|
| 3405 | n = "UngrabMouse";
|
---|
| 3406 | break;
|
---|
| 3407 | case QEvent::GrabKeyboard:
|
---|
| 3408 | n = "GrabKeyboard";
|
---|
| 3409 | break;
|
---|
| 3410 | case QEvent::UngrabKeyboard:
|
---|
| 3411 | n = "UngrabKeyboard";
|
---|
| 3412 | break;
|
---|
| 3413 | #ifdef QT3_SUPPORT
|
---|
| 3414 | case QEvent::ChildInsertedRequest:
|
---|
| 3415 | n = "ChildInsertedRequest";
|
---|
| 3416 | break;
|
---|
| 3417 | case QEvent::ChildInserted: n = "ChildInserted";
|
---|
| 3418 | #endif
|
---|
| 3419 | case QEvent::ChildAdded: n = n ? n : "ChildAdded";
|
---|
| 3420 | case QEvent::ChildPolished: n = n ? n : "ChildPolished";
|
---|
| 3421 | case QEvent::ChildRemoved: n = n ? n : "ChildRemoved";
|
---|
| 3422 | dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
|
---|
| 3423 | return dbg.space();
|
---|
[846] | 3424 | #ifndef QT_NO_GESTURES
|
---|
[561] | 3425 | case QEvent::Gesture:
|
---|
| 3426 | n = "Gesture";
|
---|
| 3427 | break;
|
---|
[846] | 3428 | #endif
|
---|
[2] | 3429 | default:
|
---|
| 3430 | dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
|
---|
| 3431 | return dbg.space();
|
---|
| 3432 | }
|
---|
| 3433 |
|
---|
| 3434 | dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
|
---|
| 3435 | return dbg.space();
|
---|
| 3436 | #else
|
---|
| 3437 | qWarning("This compiler doesn't support streaming QEvent to QDebug");
|
---|
| 3438 | return dbg;
|
---|
| 3439 | Q_UNUSED(e);
|
---|
| 3440 | #endif
|
---|
| 3441 | }
|
---|
| 3442 | #endif
|
---|
| 3443 |
|
---|
| 3444 | #ifndef QT_NO_CLIPBOARD
|
---|
| 3445 | /*!
|
---|
| 3446 | \class QClipboardEvent
|
---|
| 3447 | \ingroup events
|
---|
| 3448 | \internal
|
---|
| 3449 |
|
---|
| 3450 | \brief The QClipboardEvent class provides the parameters used in a clipboard event.
|
---|
| 3451 |
|
---|
| 3452 | This class is for internal use only, and exists to aid the clipboard on various
|
---|
| 3453 | platforms to get all the information it needs. Use QEvent::Clipboard instead.
|
---|
| 3454 |
|
---|
| 3455 | \sa QClipboard
|
---|
| 3456 | */
|
---|
| 3457 |
|
---|
| 3458 | QClipboardEvent::QClipboardEvent(QEventPrivate *data)
|
---|
| 3459 | : QEvent(QEvent::Clipboard)
|
---|
| 3460 | {
|
---|
| 3461 | d = data;
|
---|
| 3462 | }
|
---|
| 3463 |
|
---|
| 3464 | QClipboardEvent::~QClipboardEvent()
|
---|
| 3465 | {
|
---|
| 3466 | }
|
---|
| 3467 | #endif // QT_NO_CLIPBOARD
|
---|
| 3468 |
|
---|
| 3469 | /*!
|
---|
| 3470 | \class QShortcutEvent
|
---|
| 3471 | \brief The QShortcutEvent class provides an event which is generated when
|
---|
| 3472 | the user presses a key combination.
|
---|
| 3473 |
|
---|
| 3474 | \ingroup events
|
---|
| 3475 |
|
---|
| 3476 | Normally you don't need to use this class directly; QShortcut
|
---|
| 3477 | provides a higher-level interface to handle shortcut keys.
|
---|
| 3478 |
|
---|
| 3479 | \sa QShortcut
|
---|
| 3480 | */
|
---|
| 3481 |
|
---|
| 3482 | /*!
|
---|
| 3483 | \fn const QKeySequence &QShortcutEvent::key() const
|
---|
| 3484 |
|
---|
| 3485 | Returns the key sequence that triggered the event.
|
---|
| 3486 | */
|
---|
| 3487 |
|
---|
| 3488 | // ### Qt 5: remove
|
---|
| 3489 | /*!
|
---|
| 3490 | \fn const QKeySequence &QShortcutEvent::key()
|
---|
| 3491 |
|
---|
| 3492 | \internal
|
---|
| 3493 | */
|
---|
| 3494 |
|
---|
| 3495 | /*!
|
---|
| 3496 | \fn int QShortcutEvent::shortcutId() const
|
---|
| 3497 |
|
---|
| 3498 | Returns the ID of the QShortcut object for which this event was
|
---|
| 3499 | generated.
|
---|
| 3500 |
|
---|
| 3501 | \sa QShortcut::id()
|
---|
| 3502 | */
|
---|
| 3503 |
|
---|
| 3504 | // ### Qt 5: remove
|
---|
| 3505 | /*!
|
---|
| 3506 | \fn int QShortcutEvent::shortcutId()
|
---|
| 3507 | \overload
|
---|
| 3508 |
|
---|
| 3509 | \internal
|
---|
| 3510 | */
|
---|
| 3511 |
|
---|
| 3512 | /*!
|
---|
| 3513 | \fn bool QShortcutEvent::isAmbiguous() const
|
---|
| 3514 |
|
---|
| 3515 | Returns true if the key sequence that triggered the event is
|
---|
| 3516 | ambiguous.
|
---|
| 3517 |
|
---|
| 3518 | \sa QShortcut::activatedAmbiguously()
|
---|
| 3519 | */
|
---|
| 3520 |
|
---|
| 3521 | // ### Qt 5: remove
|
---|
| 3522 | /*!
|
---|
| 3523 | \fn bool QShortcutEvent::isAmbiguous()
|
---|
| 3524 |
|
---|
| 3525 | \internal
|
---|
| 3526 | */
|
---|
| 3527 |
|
---|
| 3528 | /*!
|
---|
| 3529 | \class QWindowStateChangeEvent
|
---|
| 3530 | \ingroup events
|
---|
| 3531 |
|
---|
| 3532 | \brief The QWindowStateChangeEvent class provides the window state before a
|
---|
| 3533 | window state change.
|
---|
| 3534 | */
|
---|
| 3535 |
|
---|
| 3536 | /*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
|
---|
| 3537 |
|
---|
| 3538 | Returns the state of the window before the change.
|
---|
| 3539 | */
|
---|
| 3540 |
|
---|
| 3541 | /*! \internal
|
---|
| 3542 | */
|
---|
| 3543 | QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s)
|
---|
| 3544 | : QEvent(WindowStateChange), ostate(s)
|
---|
| 3545 | {
|
---|
| 3546 | }
|
---|
| 3547 |
|
---|
| 3548 | /*! \internal
|
---|
| 3549 | */
|
---|
| 3550 | QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
|
---|
| 3551 | : QEvent(WindowStateChange), ostate(s)
|
---|
| 3552 | {
|
---|
| 3553 | if (isOverride)
|
---|
| 3554 | d = (QEventPrivate*)(this);
|
---|
| 3555 | }
|
---|
| 3556 |
|
---|
| 3557 | /*! \internal
|
---|
| 3558 | */
|
---|
| 3559 | bool QWindowStateChangeEvent::isOverride() const
|
---|
| 3560 | {
|
---|
| 3561 | return (d != 0);
|
---|
| 3562 | }
|
---|
| 3563 |
|
---|
| 3564 | /*! \internal
|
---|
| 3565 | */
|
---|
| 3566 | QWindowStateChangeEvent::~QWindowStateChangeEvent()
|
---|
| 3567 | {
|
---|
| 3568 | }
|
---|
| 3569 |
|
---|
| 3570 | #ifdef QT3_SUPPORT
|
---|
| 3571 |
|
---|
| 3572 | /*!
|
---|
| 3573 | \class QMenubarUpdatedEvent
|
---|
| 3574 | \internal
|
---|
| 3575 | Event sent by QMenuBar to tell Q3Workspace to update itself.
|
---|
| 3576 | */
|
---|
| 3577 |
|
---|
| 3578 | /*! \internal
|
---|
| 3579 |
|
---|
| 3580 | */
|
---|
| 3581 | QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
|
---|
| 3582 | :QEvent(QEvent::MenubarUpdated), m_menuBar(menuBar) {}
|
---|
| 3583 |
|
---|
| 3584 | /*!
|
---|
| 3585 | \fn QMenuBar *QMenubarUpdatedEvent::menuBar()
|
---|
| 3586 | \internal
|
---|
| 3587 | */
|
---|
| 3588 |
|
---|
| 3589 | /*!
|
---|
| 3590 | \fn bool operator==(QKeyEvent *e, QKeySequence::StandardKey key)
|
---|
| 3591 |
|
---|
| 3592 | \relates QKeyEvent
|
---|
| 3593 |
|
---|
| 3594 | Returns true if \a key is currently bound to the key combination
|
---|
| 3595 | specified by \a e.
|
---|
| 3596 |
|
---|
| 3597 | Equivalent to \c {e->matches(key)}.
|
---|
| 3598 | */
|
---|
| 3599 |
|
---|
| 3600 | /*!
|
---|
| 3601 | \fn bool operator==(QKeySequence::StandardKey key, QKeyEvent *e)
|
---|
| 3602 |
|
---|
| 3603 | \relates QKeyEvent
|
---|
| 3604 |
|
---|
| 3605 | Returns true if \a key is currently bound to the key combination
|
---|
| 3606 | specified by \a e.
|
---|
| 3607 |
|
---|
| 3608 | Equivalent to \c {e->matches(key)}.
|
---|
| 3609 | */
|
---|
| 3610 |
|
---|
| 3611 | /*!
|
---|
| 3612 | \internal
|
---|
| 3613 |
|
---|
| 3614 | \class QKeyEventEx
|
---|
| 3615 | \ingroup events
|
---|
| 3616 |
|
---|
| 3617 | \brief The QKeyEventEx class provides more extended information about a keyevent.
|
---|
| 3618 |
|
---|
| 3619 | This class is for internal use only, and exists to aid the shortcut system on
|
---|
| 3620 | various platforms to get all the information it needs.
|
---|
| 3621 | */
|
---|
| 3622 |
|
---|
| 3623 | #endif
|
---|
| 3624 |
|
---|
[561] | 3625 | /*!
|
---|
| 3626 | \class QTouchEvent
|
---|
| 3627 | \brief The QTouchEvent class contains parameters that describe a touch event.
|
---|
| 3628 | \since 4.6
|
---|
| 3629 | \ingroup events
|
---|
[846] | 3630 | \ingroup touch
|
---|
[561] | 3631 |
|
---|
| 3632 | \section1 Enabling Touch Events
|
---|
| 3633 |
|
---|
| 3634 | Touch events occur when pressing, releasing, or moving one or more touch points on a touch
|
---|
| 3635 | device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
|
---|
| 3636 | Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
|
---|
| 3637 | \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
|
---|
| 3638 |
|
---|
| 3639 | When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouchEvents
|
---|
| 3640 | attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
|
---|
| 3641 |
|
---|
| 3642 | Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
|
---|
| 3643 | widget, and the widget will receive all updates for the touch point until it is released.
|
---|
[846] | 3644 | Note that it is possible for a widget to receive events for numerous touch points, and that
|
---|
[561] | 3645 | multiple widgets may be receiving touch events at the same time.
|
---|
| 3646 |
|
---|
| 3647 | \section1 Event Handling
|
---|
| 3648 |
|
---|
| 3649 | All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, or QEvent::TouchEnd.
|
---|
| 3650 | Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for widgets and
|
---|
| 3651 | QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
|
---|
| 3652 |
|
---|
| 3653 | The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
|
---|
| 3654 | accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
|
---|
| 3655 | filtered by an event filter, then no further touch events are sent until the next
|
---|
| 3656 | QEvent::TouchBegin.
|
---|
| 3657 |
|
---|
| 3658 | The touchPoints() function returns a list of all touch points contained in the event.
|
---|
| 3659 | Information about each touch point can be retrieved using the QTouchEvent::TouchPoint class.
|
---|
| 3660 | The Qt::TouchPointState enum describes the different states that a touch point may have.
|
---|
| 3661 |
|
---|
| 3662 | \section1 Event Delivery and Propagation
|
---|
| 3663 |
|
---|
| 3664 | By default, QWidget::event() translates the first non-primary touch point in a QTouchEvent into
|
---|
| 3665 | a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
|
---|
| 3666 | normally handle QTouchEvent. See below for information on some special considerations needed
|
---|
| 3667 | when doing this.
|
---|
| 3668 |
|
---|
| 3669 | QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
|
---|
| 3670 | contains a special accept flag that indicates whether the receiver wants the event. By default,
|
---|
| 3671 | the event is accepted. You should call ignore() if the touch event is not handled by your
|
---|
| 3672 | widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
|
---|
| 3673 | accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
|
---|
| 3674 | QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
|
---|
| 3675 | propagation for QGraphicsItems).
|
---|
| 3676 |
|
---|
| 3677 | \section1 Touch Point Grouping
|
---|
| 3678 |
|
---|
| 3679 | As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the
|
---|
| 3680 | same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same
|
---|
| 3681 | widget, which could theoretically happen during propagation if, for example, the user touched 2
|
---|
| 3682 | separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event.
|
---|
| 3683 |
|
---|
| 3684 | To avoid this, Qt will group new touch points together using the following rules:
|
---|
| 3685 |
|
---|
| 3686 | \list
|
---|
| 3687 |
|
---|
| 3688 | \i When the first touch point is detected, the destination widget is determined firstly by the
|
---|
| 3689 | location on screen and secondly by the propagation rules.
|
---|
| 3690 |
|
---|
| 3691 | \i When additional touch points are detected, Qt first looks to see if there are any active
|
---|
| 3692 | touch points on any ancestor or descendent of the widget under the new touch point. If there
|
---|
| 3693 | are, the new touch point is grouped with the first, and the new touch point will be sent in a
|
---|
| 3694 | single QTouchEvent to the widget that handled the first touch point. (The widget under the new
|
---|
| 3695 | touch point will not receive an event).
|
---|
| 3696 |
|
---|
| 3697 | \endlist
|
---|
| 3698 |
|
---|
| 3699 | This makes it possible for sibling widgets to handle touch events independently while making
|
---|
| 3700 | sure that the sequence of QTouchEvents is always correct.
|
---|
| 3701 |
|
---|
| 3702 | \section1 Mouse Events and the Primary Touch Point
|
---|
| 3703 |
|
---|
| 3704 | QTouchEvent delivery is independent from that of QMouseEvent. On some windowing systems, mouse
|
---|
| 3705 | events are also sent for the \l{QTouchEvent::TouchPoint::isPrimary()}{primary touch point}.
|
---|
| 3706 | This means it is possible for your widget to receive both QTouchEvent and QMouseEvent for the
|
---|
| 3707 | same user interaction point. You can use the QTouchEvent::TouchPoint::isPrimary() function to
|
---|
| 3708 | identify the primary touch point.
|
---|
| 3709 |
|
---|
| 3710 | Note that on some systems, it is possible to receive touch events without a primary touch
|
---|
| 3711 | point. All this means is that there will be no mouse event generated for the touch points in
|
---|
| 3712 | the QTouchEvent.
|
---|
| 3713 |
|
---|
| 3714 | \section1 Caveats
|
---|
| 3715 |
|
---|
| 3716 | \list
|
---|
| 3717 |
|
---|
| 3718 | \i As mentioned above, enabling touch events means multiple widgets can be receiving touch
|
---|
| 3719 | events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
|
---|
[846] | 3720 | this gives you great flexibility in designing touch user interfaces. Be aware of the
|
---|
[561] | 3721 | implications. For example, it is possible that the user is moving a QSlider with one finger and
|
---|
| 3722 | pressing a QPushButton with another. The signals emitted by these widgets will be
|
---|
| 3723 | interleaved.
|
---|
| 3724 |
|
---|
| 3725 | \i Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
|
---|
| 3726 | QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
|
---|
| 3727 | recipients, recursion may cause problems, including but not limited to lost events
|
---|
| 3728 | and unexpected infinite recursion.
|
---|
| 3729 |
|
---|
| 3730 | \i QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
|
---|
| 3731 | \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
|
---|
[846] | 3732 | undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
|
---|
[561] | 3733 | points.
|
---|
| 3734 |
|
---|
| 3735 | \endlist
|
---|
| 3736 |
|
---|
| 3737 | \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
|
---|
| 3738 | QGraphicsItem::acceptTouchEvents()
|
---|
| 3739 | */
|
---|
| 3740 |
|
---|
| 3741 | /*! \enum Qt::TouchPointState
|
---|
| 3742 | \since 4.6
|
---|
| 3743 |
|
---|
| 3744 | This enum represents the state of a touch point at the time the
|
---|
| 3745 | QTouchEvent occurred.
|
---|
| 3746 |
|
---|
| 3747 | \value TouchPointPressed The touch point is now pressed.
|
---|
| 3748 | \value TouchPointMoved The touch point moved.
|
---|
| 3749 | \value TouchPointStationary The touch point did not move.
|
---|
| 3750 | \value TouchPointReleased The touch point was released.
|
---|
| 3751 |
|
---|
| 3752 | \omitvalue TouchPointStateMask
|
---|
| 3753 | \omitvalue TouchPointPrimary
|
---|
| 3754 | */
|
---|
| 3755 |
|
---|
| 3756 | /*! \enum QTouchEvent::DeviceType
|
---|
| 3757 |
|
---|
| 3758 | This enum represents the type of device that generated a QTouchEvent.
|
---|
| 3759 |
|
---|
| 3760 | \value TouchScreen In this type of device, the touch surface and display are integrated. This
|
---|
| 3761 | means the surface and display typically have the same size, such that there
|
---|
| 3762 | is a direct relationship between the touch points' physical positions and the
|
---|
| 3763 | coordinate reported by QTouchEvent::TouchPoint. As a result, Qt allows the
|
---|
| 3764 | user to interact directly with multiple QWidgets and QGraphicsItems at the
|
---|
| 3765 | same time.
|
---|
| 3766 |
|
---|
| 3767 | \value TouchPad In this type of device, the touch surface is separate from the display. There
|
---|
| 3768 | is not a direct relationship between the physical touch location and the
|
---|
| 3769 | on-screen coordinates. Instead, they are calculated relative to the current
|
---|
| 3770 | mouse position, and the user must use the touch-pad to move this reference
|
---|
| 3771 | point. Unlike touch-screens, Qt allows users to only interact with a single
|
---|
| 3772 | QWidget or QGraphicsItem at a time.
|
---|
| 3773 | */
|
---|
| 3774 |
|
---|
| 3775 | /*!
|
---|
| 3776 | Constructs a QTouchEvent with the given \a eventType, \a deviceType, and \a touchPoints.
|
---|
| 3777 | The \a touchPointStates and \a modifiers are the current touch point states and keyboard
|
---|
| 3778 | modifiers at the time of the event.
|
---|
| 3779 | */
|
---|
| 3780 | QTouchEvent::QTouchEvent(QEvent::Type eventType,
|
---|
| 3781 | QTouchEvent::DeviceType deviceType,
|
---|
| 3782 | Qt::KeyboardModifiers modifiers,
|
---|
| 3783 | Qt::TouchPointStates touchPointStates,
|
---|
| 3784 | const QList<QTouchEvent::TouchPoint> &touchPoints)
|
---|
| 3785 | : QInputEvent(eventType, modifiers),
|
---|
| 3786 | _widget(0),
|
---|
| 3787 | _deviceType(deviceType),
|
---|
| 3788 | _touchPointStates(touchPointStates),
|
---|
| 3789 | _touchPoints(touchPoints)
|
---|
| 3790 | { }
|
---|
| 3791 |
|
---|
| 3792 | /*!
|
---|
| 3793 | Destroys the QTouchEvent.
|
---|
| 3794 | */
|
---|
| 3795 | QTouchEvent::~QTouchEvent()
|
---|
| 3796 | { }
|
---|
| 3797 |
|
---|
| 3798 | /*! \fn QWidget *QTouchEvent::widget() const
|
---|
| 3799 |
|
---|
| 3800 | Returns the widget on which the event occurred.
|
---|
| 3801 | */
|
---|
| 3802 |
|
---|
| 3803 |
|
---|
| 3804 | /*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
|
---|
| 3805 |
|
---|
| 3806 | Returns a bitwise OR of all the touch point states for this event.
|
---|
| 3807 | */
|
---|
| 3808 |
|
---|
| 3809 | /*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const
|
---|
| 3810 |
|
---|
| 3811 | Returns the list of touch points contained in the touch event.
|
---|
| 3812 | */
|
---|
| 3813 |
|
---|
| 3814 | /*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
|
---|
| 3815 |
|
---|
| 3816 | Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
|
---|
| 3817 | */
|
---|
| 3818 |
|
---|
| 3819 | /*! \fn void QTouchEvent::setWidget(QWidget *widget)
|
---|
| 3820 |
|
---|
| 3821 | \internal
|
---|
| 3822 |
|
---|
| 3823 | Sets the widget for this event.
|
---|
| 3824 | */
|
---|
| 3825 |
|
---|
| 3826 | /*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
|
---|
| 3827 |
|
---|
| 3828 | \internal
|
---|
| 3829 |
|
---|
| 3830 | Sets a bitwise OR of all the touch point states for this event.
|
---|
| 3831 | */
|
---|
| 3832 |
|
---|
| 3833 | /*! \fn void QTouchEvent::setTouchPoints(const QList<QTouchEvent::TouchPoint> &touchPoints)
|
---|
| 3834 |
|
---|
| 3835 | \internal
|
---|
| 3836 |
|
---|
| 3837 | Sets the list of touch points for this event.
|
---|
| 3838 | */
|
---|
| 3839 |
|
---|
| 3840 | /*! \fn void QTouchEvent::setDeviceType(DeviceType deviceType)
|
---|
| 3841 |
|
---|
| 3842 | \internal
|
---|
| 3843 |
|
---|
| 3844 | Sets the device type to \a deviceType, which is of type \l {QTouchEvent::DeviceType}
|
---|
| 3845 | {DeviceType}.
|
---|
| 3846 | */
|
---|
| 3847 |
|
---|
| 3848 | /*! \class QTouchEvent::TouchPoint
|
---|
| 3849 | \brief The TouchPoint class provides information about a touch point in a QTouchEvent.
|
---|
| 3850 | \since 4.6
|
---|
| 3851 | */
|
---|
| 3852 |
|
---|
| 3853 | /*! \internal
|
---|
| 3854 |
|
---|
| 3855 | Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
|
---|
| 3856 | */
|
---|
| 3857 | QTouchEvent::TouchPoint::TouchPoint(int id)
|
---|
| 3858 | : d(new QTouchEventTouchPointPrivate(id))
|
---|
| 3859 | { }
|
---|
| 3860 |
|
---|
| 3861 | /*! \internal
|
---|
| 3862 |
|
---|
| 3863 | Constructs a copy of \a other.
|
---|
| 3864 | */
|
---|
| 3865 | QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
|
---|
| 3866 | : d(other.d)
|
---|
| 3867 | {
|
---|
| 3868 | d->ref.ref();
|
---|
| 3869 | }
|
---|
| 3870 |
|
---|
| 3871 | /*! \internal
|
---|
| 3872 |
|
---|
| 3873 | Destroys the QTouchEvent::TouchPoint.
|
---|
| 3874 | */
|
---|
| 3875 | QTouchEvent::TouchPoint::~TouchPoint()
|
---|
| 3876 | {
|
---|
| 3877 | if (!d->ref.deref())
|
---|
| 3878 | delete d;
|
---|
| 3879 | }
|
---|
| 3880 |
|
---|
| 3881 | /*!
|
---|
| 3882 | Returns the id number of this touch point.
|
---|
| 3883 |
|
---|
| 3884 | Id numbers are globally sequential, starting at zero, meaning the
|
---|
| 3885 | first touch point in the application has id 0, the second has id 1,
|
---|
| 3886 | and so on.
|
---|
| 3887 | */
|
---|
| 3888 | int QTouchEvent::TouchPoint::id() const
|
---|
| 3889 | {
|
---|
| 3890 | return d->id;
|
---|
| 3891 | }
|
---|
| 3892 |
|
---|
| 3893 | /*!
|
---|
| 3894 | Returns the current state of this touch point.
|
---|
| 3895 | */
|
---|
| 3896 | Qt::TouchPointState QTouchEvent::TouchPoint::state() const
|
---|
| 3897 | {
|
---|
| 3898 | return Qt::TouchPointState(int(d->state) & Qt::TouchPointStateMask);
|
---|
| 3899 | }
|
---|
| 3900 |
|
---|
| 3901 | /*!
|
---|
| 3902 | Returns true if this touch point is the primary touch point. The primary touch point is the
|
---|
| 3903 | point for which the windowing system generates mouse events.
|
---|
| 3904 | */
|
---|
| 3905 | bool QTouchEvent::TouchPoint::isPrimary() const
|
---|
| 3906 | {
|
---|
| 3907 | return (d->state & Qt::TouchPointPrimary) != 0;
|
---|
| 3908 | }
|
---|
| 3909 |
|
---|
| 3910 | /*!
|
---|
| 3911 | Returns the position of this touch point, relative to the widget
|
---|
| 3912 | or QGraphicsItem that received the event.
|
---|
| 3913 |
|
---|
| 3914 | \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
|
---|
| 3915 | */
|
---|
| 3916 | QPointF QTouchEvent::TouchPoint::pos() const
|
---|
| 3917 | {
|
---|
| 3918 | return d->rect.center();
|
---|
| 3919 | }
|
---|
| 3920 |
|
---|
| 3921 | /*!
|
---|
| 3922 | Returns the scene position of this touch point.
|
---|
| 3923 |
|
---|
| 3924 | The scene position is the position in QGraphicsScene coordinates
|
---|
| 3925 | if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
|
---|
| 3926 | reimplementation, and identical to the screen position for
|
---|
| 3927 | widgets.
|
---|
| 3928 |
|
---|
| 3929 | \sa startScenePos(), lastScenePos(), pos()
|
---|
| 3930 | */
|
---|
| 3931 | QPointF QTouchEvent::TouchPoint::scenePos() const
|
---|
| 3932 | {
|
---|
| 3933 | return d->sceneRect.center();
|
---|
| 3934 | }
|
---|
| 3935 |
|
---|
| 3936 | /*!
|
---|
| 3937 | Returns the screen position of this touch point.
|
---|
| 3938 |
|
---|
| 3939 | \sa startScreenPos(), lastScreenPos(), pos()
|
---|
| 3940 | */
|
---|
| 3941 | QPointF QTouchEvent::TouchPoint::screenPos() const
|
---|
| 3942 | {
|
---|
| 3943 | return d->screenRect.center();
|
---|
| 3944 | }
|
---|
| 3945 |
|
---|
| 3946 | /*!
|
---|
| 3947 | Returns the normalized position of this touch point.
|
---|
| 3948 |
|
---|
| 3949 | The coordinates are normalized to the size of the touch device,
|
---|
| 3950 | i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
|
---|
| 3951 |
|
---|
| 3952 | \sa startNormalizedPos(), lastNormalizedPos(), pos()
|
---|
| 3953 | */
|
---|
| 3954 | QPointF QTouchEvent::TouchPoint::normalizedPos() const
|
---|
| 3955 | {
|
---|
| 3956 | return d->normalizedPos;
|
---|
| 3957 | }
|
---|
| 3958 |
|
---|
| 3959 | /*!
|
---|
| 3960 | Returns the starting position of this touch point, relative to the
|
---|
| 3961 | widget or QGraphicsItem that received the event.
|
---|
| 3962 |
|
---|
| 3963 | \sa pos(), lastPos()
|
---|
| 3964 | */
|
---|
| 3965 | QPointF QTouchEvent::TouchPoint::startPos() const
|
---|
| 3966 | {
|
---|
| 3967 | return d->startPos;
|
---|
| 3968 | }
|
---|
| 3969 |
|
---|
| 3970 | /*!
|
---|
| 3971 | Returns the starting scene position of this touch point.
|
---|
| 3972 |
|
---|
| 3973 | The scene position is the position in QGraphicsScene coordinates
|
---|
| 3974 | if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
|
---|
| 3975 | reimplementation, and identical to the screen position for
|
---|
| 3976 | widgets.
|
---|
| 3977 |
|
---|
| 3978 | \sa scenePos(), lastScenePos()
|
---|
| 3979 | */
|
---|
| 3980 | QPointF QTouchEvent::TouchPoint::startScenePos() const
|
---|
| 3981 | {
|
---|
| 3982 | return d->startScenePos;
|
---|
| 3983 | }
|
---|
| 3984 |
|
---|
| 3985 | /*!
|
---|
| 3986 | Returns the starting screen position of this touch point.
|
---|
| 3987 |
|
---|
| 3988 | \sa screenPos(), lastScreenPos()
|
---|
| 3989 | */
|
---|
| 3990 | QPointF QTouchEvent::TouchPoint::startScreenPos() const
|
---|
| 3991 | {
|
---|
| 3992 | return d->startScreenPos;
|
---|
| 3993 | }
|
---|
| 3994 |
|
---|
| 3995 | /*!
|
---|
| 3996 | Returns the normalized starting position of this touch point.
|
---|
| 3997 |
|
---|
| 3998 | The coordinates are normalized to the size of the touch device,
|
---|
| 3999 | i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
|
---|
| 4000 |
|
---|
| 4001 | \sa normalizedPos(), lastNormalizedPos()
|
---|
| 4002 | */
|
---|
| 4003 | QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
|
---|
| 4004 | {
|
---|
| 4005 | return d->startNormalizedPos;
|
---|
| 4006 | }
|
---|
| 4007 |
|
---|
| 4008 | /*!
|
---|
| 4009 | Returns the position of this touch point from the previous touch
|
---|
| 4010 | event, relative to the widget or QGraphicsItem that received the event.
|
---|
| 4011 |
|
---|
| 4012 | \sa pos(), startPos()
|
---|
| 4013 | */
|
---|
| 4014 | QPointF QTouchEvent::TouchPoint::lastPos() const
|
---|
| 4015 | {
|
---|
| 4016 | return d->lastPos;
|
---|
| 4017 | }
|
---|
| 4018 |
|
---|
| 4019 | /*!
|
---|
| 4020 | Returns the scene position of this touch point from the previous
|
---|
| 4021 | touch event.
|
---|
| 4022 |
|
---|
| 4023 | The scene position is the position in QGraphicsScene coordinates
|
---|
| 4024 | if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
|
---|
| 4025 | reimplementation, and identical to the screen position for
|
---|
| 4026 | widgets.
|
---|
| 4027 |
|
---|
| 4028 | \sa scenePos(), startScenePos()
|
---|
| 4029 | */
|
---|
| 4030 | QPointF QTouchEvent::TouchPoint::lastScenePos() const
|
---|
| 4031 | {
|
---|
| 4032 | return d->lastScenePos;
|
---|
| 4033 | }
|
---|
| 4034 |
|
---|
| 4035 | /*!
|
---|
| 4036 | Returns the screen position of this touch point from the previous
|
---|
| 4037 | touch event.
|
---|
| 4038 |
|
---|
| 4039 | \sa screenPos(), startScreenPos()
|
---|
| 4040 | */
|
---|
| 4041 | QPointF QTouchEvent::TouchPoint::lastScreenPos() const
|
---|
| 4042 | {
|
---|
| 4043 | return d->lastScreenPos;
|
---|
| 4044 | }
|
---|
| 4045 |
|
---|
| 4046 | /*!
|
---|
| 4047 | Returns the normalized position of this touch point from the
|
---|
| 4048 | previous touch event.
|
---|
| 4049 |
|
---|
| 4050 | The coordinates are normalized to the size of the touch device,
|
---|
| 4051 | i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
|
---|
| 4052 |
|
---|
| 4053 | \sa normalizedPos(), startNormalizedPos()
|
---|
| 4054 | */
|
---|
| 4055 | QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
|
---|
| 4056 | {
|
---|
| 4057 | return d->lastNormalizedPos;
|
---|
| 4058 | }
|
---|
| 4059 |
|
---|
| 4060 | /*!
|
---|
| 4061 | Returns the rect for this touch point, relative to the widget
|
---|
| 4062 | or QGraphicsItem that received the event. The rect is centered
|
---|
| 4063 | around the point returned by pos().
|
---|
| 4064 |
|
---|
| 4065 | \note This function returns an empty rect if the device does not report touch point sizes.
|
---|
| 4066 | */
|
---|
| 4067 | QRectF QTouchEvent::TouchPoint::rect() const
|
---|
| 4068 | {
|
---|
| 4069 | return d->rect;
|
---|
| 4070 | }
|
---|
| 4071 |
|
---|
| 4072 | /*!
|
---|
| 4073 | Returns the rect for this touch point in scene coordinates.
|
---|
| 4074 |
|
---|
| 4075 | \note This function returns an empty rect if the device does not report touch point sizes.
|
---|
| 4076 |
|
---|
| 4077 | \sa scenePos(), rect()
|
---|
| 4078 | */
|
---|
| 4079 | QRectF QTouchEvent::TouchPoint::sceneRect() const
|
---|
| 4080 | {
|
---|
| 4081 | return d->sceneRect;
|
---|
| 4082 | }
|
---|
| 4083 |
|
---|
| 4084 | /*!
|
---|
| 4085 | Returns the rect for this touch point in screen coordinates.
|
---|
| 4086 |
|
---|
| 4087 | \note This function returns an empty rect if the device does not report touch point sizes.
|
---|
| 4088 |
|
---|
| 4089 | \sa screenPos(), rect()
|
---|
| 4090 | */
|
---|
| 4091 | QRectF QTouchEvent::TouchPoint::screenRect() const
|
---|
| 4092 | {
|
---|
| 4093 | return d->screenRect;
|
---|
| 4094 | }
|
---|
| 4095 |
|
---|
| 4096 | /*!
|
---|
| 4097 | Returns the pressure of this touch point. The return value is in
|
---|
| 4098 | the range 0.0 to 1.0.
|
---|
| 4099 | */
|
---|
| 4100 | qreal QTouchEvent::TouchPoint::pressure() const
|
---|
| 4101 | {
|
---|
| 4102 | return d->pressure;
|
---|
| 4103 | }
|
---|
| 4104 |
|
---|
| 4105 | /*! \internal */
|
---|
| 4106 | void QTouchEvent::TouchPoint::setId(int id)
|
---|
| 4107 | {
|
---|
| 4108 | if (d->ref != 1)
|
---|
| 4109 | d = d->detach();
|
---|
| 4110 | d->id = id;
|
---|
| 4111 | }
|
---|
| 4112 |
|
---|
| 4113 | /*! \internal */
|
---|
| 4114 | void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
|
---|
| 4115 | {
|
---|
| 4116 | if (d->ref != 1)
|
---|
| 4117 | d = d->detach();
|
---|
| 4118 | d->state = state;
|
---|
| 4119 | }
|
---|
| 4120 |
|
---|
| 4121 | /*! \internal */
|
---|
| 4122 | void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
|
---|
| 4123 | {
|
---|
| 4124 | if (d->ref != 1)
|
---|
| 4125 | d = d->detach();
|
---|
| 4126 | d->rect.moveCenter(pos);
|
---|
| 4127 | }
|
---|
| 4128 |
|
---|
| 4129 | /*! \internal */
|
---|
| 4130 | void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
|
---|
| 4131 | {
|
---|
| 4132 | if (d->ref != 1)
|
---|
| 4133 | d = d->detach();
|
---|
| 4134 | d->sceneRect.moveCenter(scenePos);
|
---|
| 4135 | }
|
---|
| 4136 |
|
---|
| 4137 | /*! \internal */
|
---|
| 4138 | void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
|
---|
| 4139 | {
|
---|
| 4140 | if (d->ref != 1)
|
---|
| 4141 | d = d->detach();
|
---|
| 4142 | d->screenRect.moveCenter(screenPos);
|
---|
| 4143 | }
|
---|
| 4144 |
|
---|
| 4145 | /*! \internal */
|
---|
| 4146 | void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
|
---|
| 4147 | {
|
---|
| 4148 | if (d->ref != 1)
|
---|
| 4149 | d = d->detach();
|
---|
| 4150 | d->normalizedPos = normalizedPos;
|
---|
| 4151 | }
|
---|
| 4152 |
|
---|
| 4153 | /*! \internal */
|
---|
| 4154 | void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
|
---|
| 4155 | {
|
---|
| 4156 | if (d->ref != 1)
|
---|
| 4157 | d = d->detach();
|
---|
| 4158 | d->startPos = startPos;
|
---|
| 4159 | }
|
---|
| 4160 |
|
---|
| 4161 | /*! \internal */
|
---|
| 4162 | void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
|
---|
| 4163 | {
|
---|
| 4164 | if (d->ref != 1)
|
---|
| 4165 | d = d->detach();
|
---|
| 4166 | d->startScenePos = startScenePos;
|
---|
| 4167 | }
|
---|
| 4168 |
|
---|
| 4169 | /*! \internal */
|
---|
| 4170 | void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
|
---|
| 4171 | {
|
---|
| 4172 | if (d->ref != 1)
|
---|
| 4173 | d = d->detach();
|
---|
| 4174 | d->startScreenPos = startScreenPos;
|
---|
| 4175 | }
|
---|
| 4176 |
|
---|
| 4177 | /*! \internal */
|
---|
| 4178 | void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
|
---|
| 4179 | {
|
---|
| 4180 | if (d->ref != 1)
|
---|
| 4181 | d = d->detach();
|
---|
| 4182 | d->startNormalizedPos = startNormalizedPos;
|
---|
| 4183 | }
|
---|
| 4184 |
|
---|
| 4185 | /*! \internal */
|
---|
| 4186 | void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
|
---|
| 4187 | {
|
---|
| 4188 | if (d->ref != 1)
|
---|
| 4189 | d = d->detach();
|
---|
| 4190 | d->lastPos = lastPos;
|
---|
| 4191 | }
|
---|
| 4192 |
|
---|
| 4193 | /*! \internal */
|
---|
| 4194 | void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
|
---|
| 4195 | {
|
---|
| 4196 | if (d->ref != 1)
|
---|
| 4197 | d = d->detach();
|
---|
| 4198 | d->lastScenePos = lastScenePos;
|
---|
| 4199 | }
|
---|
| 4200 |
|
---|
| 4201 | /*! \internal */
|
---|
| 4202 | void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
|
---|
| 4203 | {
|
---|
| 4204 | if (d->ref != 1)
|
---|
| 4205 | d = d->detach();
|
---|
| 4206 | d->lastScreenPos = lastScreenPos;
|
---|
| 4207 | }
|
---|
| 4208 |
|
---|
| 4209 | /*! \internal */
|
---|
| 4210 | void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
|
---|
| 4211 | {
|
---|
| 4212 | if (d->ref != 1)
|
---|
| 4213 | d = d->detach();
|
---|
| 4214 | d->lastNormalizedPos = lastNormalizedPos;
|
---|
| 4215 | }
|
---|
| 4216 |
|
---|
| 4217 | /*! \internal */
|
---|
| 4218 | void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
|
---|
| 4219 | {
|
---|
| 4220 | if (d->ref != 1)
|
---|
| 4221 | d = d->detach();
|
---|
| 4222 | d->rect = rect;
|
---|
| 4223 | }
|
---|
| 4224 |
|
---|
| 4225 | /*! \internal */
|
---|
| 4226 | void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
|
---|
| 4227 | {
|
---|
| 4228 | if (d->ref != 1)
|
---|
| 4229 | d = d->detach();
|
---|
| 4230 | d->sceneRect = sceneRect;
|
---|
| 4231 | }
|
---|
| 4232 |
|
---|
| 4233 | /*! \internal */
|
---|
| 4234 | void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
|
---|
| 4235 | {
|
---|
| 4236 | if (d->ref != 1)
|
---|
| 4237 | d = d->detach();
|
---|
| 4238 | d->screenRect = screenRect;
|
---|
| 4239 | }
|
---|
| 4240 |
|
---|
| 4241 | /*! \internal */
|
---|
| 4242 | void QTouchEvent::TouchPoint::setPressure(qreal pressure)
|
---|
| 4243 | {
|
---|
| 4244 | if (d->ref != 1)
|
---|
| 4245 | d = d->detach();
|
---|
| 4246 | d->pressure = pressure;
|
---|
| 4247 | }
|
---|
| 4248 |
|
---|
| 4249 | /*! \internal */
|
---|
| 4250 | QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::TouchPoint &other)
|
---|
| 4251 | {
|
---|
| 4252 | other.d->ref.ref();
|
---|
| 4253 | if (!d->ref.deref())
|
---|
| 4254 | delete d;
|
---|
| 4255 | d = other.d;
|
---|
| 4256 | return *this;
|
---|
| 4257 | }
|
---|
| 4258 |
|
---|
[846] | 4259 | #ifndef QT_NO_GESTURES
|
---|
[561] | 4260 | /*!
|
---|
| 4261 | \class QGestureEvent
|
---|
| 4262 | \since 4.6
|
---|
| 4263 | \ingroup events
|
---|
| 4264 | \ingroup gestures
|
---|
| 4265 |
|
---|
| 4266 | \brief The QGestureEvent class provides the description of triggered gestures.
|
---|
| 4267 |
|
---|
| 4268 | The QGestureEvent class contains a list of gestures, which can be obtained using the
|
---|
| 4269 | gestures() function.
|
---|
| 4270 |
|
---|
| 4271 | The gestures are either active or canceled. A list of those that are currently being
|
---|
| 4272 | executed can be obtained using the activeGestures() function. A list of those which
|
---|
| 4273 | were previously active and have been canceled can be accessed using the
|
---|
| 4274 | canceledGestures() function. A gesture might be canceled if the current window loses
|
---|
| 4275 | focus, for example, or because of a timeout, or for other reasons.
|
---|
| 4276 |
|
---|
| 4277 | If the event handler does not accept the event by calling the generic
|
---|
| 4278 | QEvent::accept() function, all individual QGesture object that were not
|
---|
| 4279 | accepted and in the Qt::GestureStarted state will be propagated up the
|
---|
| 4280 | parent widget chain until a widget accepts them individually, by calling
|
---|
| 4281 | QGestureEvent::accept() for each of them, or an event filter consumes the
|
---|
| 4282 | event.
|
---|
| 4283 |
|
---|
[846] | 4284 | \section1 Further Reading
|
---|
| 4285 |
|
---|
| 4286 | For an overview of gesture handling in Qt and information on using gestures
|
---|
| 4287 | in your applications, see the \l{Gestures Programming} document.
|
---|
| 4288 |
|
---|
[561] | 4289 | \sa QGesture, QGestureRecognizer,
|
---|
| 4290 | QWidget::grabGesture(), QGraphicsObject::grabGesture()
|
---|
| 4291 | */
|
---|
| 4292 |
|
---|
| 4293 | /*!
|
---|
| 4294 | Creates new QGestureEvent containing a list of \a gestures.
|
---|
| 4295 | */
|
---|
| 4296 | QGestureEvent::QGestureEvent(const QList<QGesture *> &gestures)
|
---|
| 4297 | : QEvent(QEvent::Gesture)
|
---|
| 4298 | {
|
---|
| 4299 | d = reinterpret_cast<QEventPrivate *>(new QGestureEventPrivate(gestures));
|
---|
| 4300 | }
|
---|
| 4301 |
|
---|
| 4302 | /*!
|
---|
| 4303 | Destroys QGestureEvent.
|
---|
| 4304 | */
|
---|
| 4305 | QGestureEvent::~QGestureEvent()
|
---|
| 4306 | {
|
---|
| 4307 | delete reinterpret_cast<QGestureEventPrivate *>(d);
|
---|
| 4308 | }
|
---|
| 4309 |
|
---|
| 4310 | /*!
|
---|
| 4311 | Returns all gestures that are delivered in the event.
|
---|
| 4312 | */
|
---|
| 4313 | QList<QGesture *> QGestureEvent::gestures() const
|
---|
| 4314 | {
|
---|
| 4315 | return d_func()->gestures;
|
---|
| 4316 | }
|
---|
| 4317 |
|
---|
| 4318 | /*!
|
---|
| 4319 | Returns a gesture object by \a type.
|
---|
| 4320 | */
|
---|
| 4321 | QGesture *QGestureEvent::gesture(Qt::GestureType type) const
|
---|
| 4322 | {
|
---|
| 4323 | const QGestureEventPrivate *d = d_func();
|
---|
| 4324 | for(int i = 0; i < d->gestures.size(); ++i)
|
---|
| 4325 | if (d->gestures.at(i)->gestureType() == type)
|
---|
| 4326 | return d->gestures.at(i);
|
---|
| 4327 | return 0;
|
---|
| 4328 | }
|
---|
| 4329 |
|
---|
| 4330 | /*!
|
---|
| 4331 | Returns a list of active (not canceled) gestures.
|
---|
| 4332 | */
|
---|
| 4333 | QList<QGesture *> QGestureEvent::activeGestures() const
|
---|
| 4334 | {
|
---|
| 4335 | QList<QGesture *> gestures;
|
---|
| 4336 | foreach (QGesture *gesture, d_func()->gestures) {
|
---|
| 4337 | if (gesture->state() != Qt::GestureCanceled)
|
---|
| 4338 | gestures.append(gesture);
|
---|
| 4339 | }
|
---|
| 4340 | return gestures;
|
---|
| 4341 | }
|
---|
| 4342 |
|
---|
| 4343 | /*!
|
---|
| 4344 | Returns a list of canceled gestures.
|
---|
| 4345 | */
|
---|
| 4346 | QList<QGesture *> QGestureEvent::canceledGestures() const
|
---|
| 4347 | {
|
---|
| 4348 | QList<QGesture *> gestures;
|
---|
| 4349 | foreach (QGesture *gesture, d_func()->gestures) {
|
---|
| 4350 | if (gesture->state() == Qt::GestureCanceled)
|
---|
| 4351 | gestures.append(gesture);
|
---|
| 4352 | }
|
---|
| 4353 | return gestures;
|
---|
| 4354 | }
|
---|
| 4355 |
|
---|
| 4356 | /*!
|
---|
| 4357 | Sets the accept flag of the given \a gesture object to the specified \a value.
|
---|
| 4358 |
|
---|
| 4359 | Setting the accept flag indicates that the event receiver wants the \a gesture.
|
---|
| 4360 | Unwanted gestures may be propagated to the parent widget.
|
---|
| 4361 |
|
---|
| 4362 | By default, gestures in events of type QEvent::Gesture are accepted, and
|
---|
| 4363 | gestures in QEvent::GestureOverride events are ignored.
|
---|
| 4364 |
|
---|
| 4365 | For convenience, the accept flag can also be set with
|
---|
| 4366 | \l{QGestureEvent::accept()}{accept(gesture)}, and cleared with
|
---|
| 4367 | \l{QGestureEvent::ignore()}{ignore(gesture)}.
|
---|
| 4368 | */
|
---|
| 4369 | void QGestureEvent::setAccepted(QGesture *gesture, bool value)
|
---|
| 4370 | {
|
---|
| 4371 | if (gesture)
|
---|
| 4372 | setAccepted(gesture->gestureType(), value);
|
---|
| 4373 | }
|
---|
| 4374 |
|
---|
| 4375 | /*!
|
---|
| 4376 | Sets the accept flag of the given \a gesture object, the equivalent of calling
|
---|
| 4377 | \l{QGestureEvent::setAccepted()}{setAccepted(gesture, true)}.
|
---|
| 4378 |
|
---|
| 4379 | Setting the accept flag indicates that the event receiver wants the
|
---|
| 4380 | gesture. Unwanted gestures may be propagated to the parent widget.
|
---|
| 4381 |
|
---|
| 4382 | \sa QGestureEvent::ignore()
|
---|
| 4383 | */
|
---|
| 4384 | void QGestureEvent::accept(QGesture *gesture)
|
---|
| 4385 | {
|
---|
| 4386 | if (gesture)
|
---|
| 4387 | setAccepted(gesture->gestureType(), true);
|
---|
| 4388 | }
|
---|
| 4389 |
|
---|
| 4390 | /*!
|
---|
| 4391 | Clears the accept flag parameter of the given \a gesture object, the equivalent
|
---|
| 4392 | of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}.
|
---|
| 4393 |
|
---|
| 4394 | Clearing the accept flag indicates that the event receiver does not
|
---|
| 4395 | want the gesture. Unwanted gestures may be propgated to the parent widget.
|
---|
| 4396 |
|
---|
| 4397 | \sa QGestureEvent::accept()
|
---|
| 4398 | */
|
---|
| 4399 | void QGestureEvent::ignore(QGesture *gesture)
|
---|
| 4400 | {
|
---|
| 4401 | if (gesture)
|
---|
| 4402 | setAccepted(gesture->gestureType(), false);
|
---|
| 4403 | }
|
---|
| 4404 |
|
---|
| 4405 | /*!
|
---|
| 4406 | Returns true if the \a gesture is accepted; otherwise returns false.
|
---|
| 4407 | */
|
---|
| 4408 | bool QGestureEvent::isAccepted(QGesture *gesture) const
|
---|
| 4409 | {
|
---|
| 4410 | return gesture ? isAccepted(gesture->gestureType()) : false;
|
---|
| 4411 | }
|
---|
| 4412 |
|
---|
| 4413 | /*!
|
---|
| 4414 | Sets the accept flag of the given \a gestureType object to the specified
|
---|
| 4415 | \a value.
|
---|
| 4416 |
|
---|
| 4417 | Setting the accept flag indicates that the event receiver wants to receive
|
---|
| 4418 | gestures of the specified type, \a gestureType. Unwanted gestures may be
|
---|
| 4419 | propagated to the parent widget.
|
---|
| 4420 |
|
---|
| 4421 | By default, gestures in events of type QEvent::Gesture are accepted, and
|
---|
| 4422 | gestures in QEvent::GestureOverride events are ignored.
|
---|
| 4423 |
|
---|
| 4424 | For convenience, the accept flag can also be set with
|
---|
| 4425 | \l{QGestureEvent::accept()}{accept(gestureType)}, and cleared with
|
---|
| 4426 | \l{QGestureEvent::ignore()}{ignore(gestureType)}.
|
---|
| 4427 | */
|
---|
| 4428 | void QGestureEvent::setAccepted(Qt::GestureType gestureType, bool value)
|
---|
| 4429 | {
|
---|
| 4430 | setAccepted(false);
|
---|
| 4431 | d_func()->accepted[gestureType] = value;
|
---|
| 4432 | }
|
---|
| 4433 |
|
---|
| 4434 | /*!
|
---|
| 4435 | Sets the accept flag of the given \a gestureType, the equivalent of calling
|
---|
| 4436 | \l{QGestureEvent::setAccepted()}{setAccepted(gestureType, true)}.
|
---|
| 4437 |
|
---|
| 4438 | Setting the accept flag indicates that the event receiver wants the
|
---|
| 4439 | gesture. Unwanted gestures may be propagated to the parent widget.
|
---|
| 4440 |
|
---|
| 4441 | \sa QGestureEvent::ignore()
|
---|
| 4442 | */
|
---|
| 4443 | void QGestureEvent::accept(Qt::GestureType gestureType)
|
---|
| 4444 | {
|
---|
| 4445 | setAccepted(gestureType, true);
|
---|
| 4446 | }
|
---|
| 4447 |
|
---|
| 4448 | /*!
|
---|
| 4449 | Clears the accept flag parameter of the given \a gestureType, the equivalent
|
---|
| 4450 | of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}.
|
---|
| 4451 |
|
---|
| 4452 | Clearing the accept flag indicates that the event receiver does not
|
---|
| 4453 | want the gesture. Unwanted gestures may be propgated to the parent widget.
|
---|
| 4454 |
|
---|
| 4455 | \sa QGestureEvent::accept()
|
---|
| 4456 | */
|
---|
| 4457 | void QGestureEvent::ignore(Qt::GestureType gestureType)
|
---|
| 4458 | {
|
---|
| 4459 | setAccepted(gestureType, false);
|
---|
| 4460 | }
|
---|
| 4461 |
|
---|
| 4462 | /*!
|
---|
| 4463 | Returns true if the gesture of type \a gestureType is accepted; otherwise
|
---|
| 4464 | returns false.
|
---|
| 4465 | */
|
---|
| 4466 | bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const
|
---|
| 4467 | {
|
---|
| 4468 | return d_func()->accepted.value(gestureType, true);
|
---|
| 4469 | }
|
---|
| 4470 |
|
---|
| 4471 | /*!
|
---|
| 4472 | \internal
|
---|
| 4473 |
|
---|
| 4474 | Sets the widget for this event to the \a widget specified.
|
---|
| 4475 | */
|
---|
| 4476 | void QGestureEvent::setWidget(QWidget *widget)
|
---|
| 4477 | {
|
---|
| 4478 | d_func()->widget = widget;
|
---|
| 4479 | }
|
---|
| 4480 |
|
---|
| 4481 | /*!
|
---|
| 4482 | Returns the widget on which the event occurred.
|
---|
| 4483 | */
|
---|
| 4484 | QWidget *QGestureEvent::widget() const
|
---|
| 4485 | {
|
---|
| 4486 | return d_func()->widget;
|
---|
| 4487 | }
|
---|
| 4488 |
|
---|
| 4489 | #ifndef QT_NO_GRAPHICSVIEW
|
---|
| 4490 | /*!
|
---|
| 4491 | Returns the scene-local coordinates if the \a gesturePoint is inside a
|
---|
| 4492 | graphics view.
|
---|
| 4493 |
|
---|
| 4494 | This functional might be useful when the gesture event is delivered to a
|
---|
| 4495 | QGraphicsObject to translate a point in screen coordinates to scene-local
|
---|
| 4496 | coordinates.
|
---|
| 4497 |
|
---|
| 4498 | \sa QPointF::isNull().
|
---|
| 4499 | */
|
---|
| 4500 | QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const
|
---|
| 4501 | {
|
---|
| 4502 | QWidget *w = widget();
|
---|
| 4503 | if (w) // we get the viewport as widget, not the graphics view
|
---|
| 4504 | w = w->parentWidget();
|
---|
| 4505 | QGraphicsView *view = qobject_cast<QGraphicsView*>(w);
|
---|
| 4506 | if (view) {
|
---|
| 4507 | return view->mapToScene(view->mapFromGlobal(gesturePoint.toPoint()));
|
---|
| 4508 | }
|
---|
| 4509 | return QPointF();
|
---|
| 4510 | }
|
---|
| 4511 | #endif //QT_NO_GRAPHICSVIEW
|
---|
| 4512 |
|
---|
| 4513 | /*!
|
---|
| 4514 | \internal
|
---|
| 4515 | */
|
---|
| 4516 | QGestureEventPrivate *QGestureEvent::d_func()
|
---|
| 4517 | {
|
---|
| 4518 | return reinterpret_cast<QGestureEventPrivate *>(d);
|
---|
| 4519 | }
|
---|
| 4520 |
|
---|
| 4521 | /*!
|
---|
| 4522 | \internal
|
---|
| 4523 | */
|
---|
| 4524 | const QGestureEventPrivate *QGestureEvent::d_func() const
|
---|
| 4525 | {
|
---|
| 4526 | return reinterpret_cast<const QGestureEventPrivate *>(d);
|
---|
| 4527 | }
|
---|
| 4528 |
|
---|
| 4529 | #ifdef Q_NO_USING_KEYWORD
|
---|
| 4530 | /*!
|
---|
| 4531 | \fn void QGestureEvent::setAccepted(bool accepted)
|
---|
| 4532 |
|
---|
| 4533 | Sets or clears the event's internal flag that determines whether it should
|
---|
| 4534 | be delivered to other objects.
|
---|
| 4535 |
|
---|
| 4536 | Calling this function with a value of true for \a accepted indicates that the
|
---|
| 4537 | caller has accepted the event and that it should not be propagated further.
|
---|
| 4538 | Calling this function with a value of false indicates that the caller has
|
---|
| 4539 | ignored the event and that it should be delivered to other objects.
|
---|
| 4540 |
|
---|
| 4541 | For convenience, the accept flag can also be set with accept(), and cleared
|
---|
| 4542 | with ignore().
|
---|
| 4543 |
|
---|
| 4544 | \sa QEvent::accepted
|
---|
| 4545 | */
|
---|
| 4546 | /*!
|
---|
| 4547 | \fn bool QGestureEvent::isAccepted() const
|
---|
| 4548 |
|
---|
| 4549 | Returns true is the event has been accepted; otherwise returns false.
|
---|
| 4550 |
|
---|
| 4551 | \sa QEvent::accepted
|
---|
| 4552 | */
|
---|
| 4553 | /*!
|
---|
| 4554 | \fn void QGestureEvent::accept()
|
---|
| 4555 |
|
---|
| 4556 | Accepts the event, the equivalent of calling setAccepted(true).
|
---|
| 4557 |
|
---|
| 4558 | \sa QEvent::accept()
|
---|
| 4559 | */
|
---|
| 4560 | /*!
|
---|
| 4561 | \fn void QGestureEvent::ignore()
|
---|
| 4562 |
|
---|
| 4563 | Ignores the event, the equivalent of calling setAccepted(false).
|
---|
| 4564 |
|
---|
| 4565 | \sa QEvent::ignore()
|
---|
| 4566 | */
|
---|
| 4567 | #endif
|
---|
| 4568 |
|
---|
[846] | 4569 | #endif // QT_NO_GESTURES
|
---|
| 4570 |
|
---|
[2] | 4571 | QT_END_NAMESPACE
|
---|