⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qevent.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    that should get added to (or replace parts of) the text of the    editor widget. It usually is a result of the input operations and    has to be inserted to the widgets text directly before the preedit    string.    If the commitString() should replace parts of the of the text in    the editor, replacementLength() will contain the number of    characters to be replaced. replacementStart() contains the position    at which characters are to be replaced relative from the start of    the preedit string.    A number of attributes control the visual appearance of the    preedit string (the visual appearance of text outside the preedit    string is controlled by the widget only). The AttributeType enum    describes the different attributes that can be set.    A class implementing QWidget::inputMethodEvent() should at least    understand and honor the \l TextFormat and \l Cursor attributes.    Since input methods need to be able to query certain properties    from the widget, the widget must also implement    QWidget::inputMethodQuery().    When receiving an input method event, the text widget has to performs the    following steps:    \list 1    \o If the widget has selected text, the selected text should get       removed.    \o Remove the text starting at replacementStart() with length       replacementLength() and replace it by the commitString(). If       replacementLength() is 0, replacementStart() gives the insertion       position for the commitString().       When doing replacement the area of the preedit       string is ignored, thus a replacement starting at -1 with a length       of 2 will remove the last character before the preedit string and       the first character afterwards, and insert the commit string       directly before the preedit string.       If the widget implements undo/redo, this operation gets added to       the undo stack.    \o If there is no current preedit string, insert the       preeditString() at the current cursor position; otherwise replace       the previous preeditString with the one received from this event.       If the widget implements undo/redo, the preeditString() should not       influence the undo/redo stack in any way.       The widget should examine the list of attributes to apply to the       preedit string. It has to understand at least the TextFormat and       Cursor attributes and render them as specified.    \endlist    \sa QInputContext*//*!    \enum QInputMethodEvent::AttributeType    \value TextFormat    A QTextCharFormat for the part of the preedit string specified by    start and length. value contains a QVariant of type QTextFormat    specifying rendering of this part of the preedit string. There    should be at most one format for every part of the preedit    string. If several are specified for any character in the string the    behaviour is undefined. A conforming implementation has to at least    honour the backgroundColor, textColor and fontUnderline properties    of the format.    \value Cursor If set, a cursor should be shown inside the preedit    string at position start. The length variable determines whether    the cursor is visible or not. If the length is 0 the cursor is    invisible. If value is a QVariant of type QColor this color will    be used for rendering the cursor, otherwise the color of the    surrounding text will be used. There should be at most one Cursor    attribute per event. If several are specified the behaviour is    undefined.    \value Language    The variant contains a QLocale object specifying the language of a    certain part of the preedit string. There should be at most one    language set for every part of the preedit string. If several are    specified for any character in the string the behaviour is undefined.    \value Ruby    The ruby text for a part of the preedit string. There should be at    most one ruby text set for every part of the preedit string. If    several are specified for any character in the string the behaviour    is undefined.    \sa Attribute*//*!    \class QInputMethodEvent::Attribute    \brief The QInputMethodEvent::Attribute class stores an input method attribute.*//*!    \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)    Constructs an input method attribute. \a type specifies the type    of attribute, \a start and \a length the position of the    attribute, and \a value the value of the attribute.*//*!    Constructs an event of type QEvent::InputMethod. The    attributes(), preeditString(), commitString(), replacementStart(),    and replacementLength() are initialized to default values.    \sa setCommitString()*/QInputMethodEvent::QInputMethodEvent()    : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0){}/*!    Construcs an event of type QEvent::InputMethod. The    preedit text is set to \a preeditText, the attributes to    \a attributes.    The commitString(), replacementStart(), and replacementLength()    values can be set using setCommitString().    \sa preeditString(), attributes()*/QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)    : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),      replace_from(0), replace_length(0){}/*!    Constructs a copy of \a other.*/QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)    : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),      commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length){}/*!    Sets the commit string to \a commitString.    The commit string is the text that should get added to (or    replace parts of) the text of the editor widget. It usually is a    result of the input operations and has to be inserted to the    widgets text directly before the preedit string.    If the commit string should replace parts of the of the text in    the editor, \a replaceLength specifies the number of    characters to be replaced. \a replaceFrom specifies the position    at which characters are to be replaced relative from the start of    the preedit string.    \sa commitString(), replacementStart(), replacementLength()*/void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength){    commit = commitString;    replace_from = replaceFrom;    replace_length = replaceLength;}/*!    \fn const QList<Attribute> &QInputMethodEvent::attributes() const    Returns the list of attributes passed to the QInputMethodEvent    constructor. The attributes control the visual appearance of the    preedit string (the visual appearance of text outside the preedit    string is controlled by the widget only).    \sa preeditString(), Attribute*//*!    \fn const QString &QInputMethodEvent::preeditString() const    Returns the preedit text, i.e. the text before the user started    editing it.    \sa commitString(), attributes()*//*!    \fn const QString &QInputMethodEvent::commitString() const    Returns the text that should get added to (or replace parts of)    the text of the editor widget. It usually is a result of the    input operations and has to be inserted to the widgets text    directly before the preedit string.    \sa setCommitString(), preeditString(), replacementStart(), replacementLength()*//*!    \fn int QInputMethodEvent::replacementStart() const    Returns the position at which characters are to be replaced relative    from the start of the preedit string.    \sa replacementLength(), setCommitString()*//*!    \fn int QInputMethodEvent::replacementLength() const    Returns the number of characters to be replaced in the preedit    string.    \sa replacementStart(), setCommitString()*//*!    \class QTabletEvent    \brief The QTabletEvent class contains parameters that describe a Tablet event.    \ingroup events    Tablet Events are generated from a Wacom tablet. Most of the time you will    want to deal with events from the tablet as if they were events from a    mouse; for example, you would retrieve the cursor position with x(), y(),    pos(), globalX(), globalY(), and globalPos(). In some situations you may    wish to retrieve the extra information provided by the tablet device    driver; for example, you might want to do subpixeling with higher    resolution coordinates or you may want to adjust color brightness based on    pressure.  QTabletEvent allows you to read the pressure(), the xTilt(), and    yTilt(), as well as the type of device being used with device() (see    \l{TabletDevice}). It can also give you the minimum and maximum values for    each device's pressure and high resolution coordinates.    A tablet event contains a special accept flag that indicates    whether the receiver wants the event. You should call    QTabletEvent::accept() if you handle the tablet event; otherwise    it will be sent to the parent widget.    The QWidget::setEnabled() function can be used to enable or    disable mouse and keyboard events for a widget.    The event handler QWidget::tabletEvent() receives all three types of    tablet events. Qt will first send a tabletEvent then, if it is not    accepted, it will send a mouse event. This allows applications that    don't utilize tablets to use a tablet like a mouse, while also    enabling those who want to use both tablets and mouses differently.*//*!    \enum QTabletEvent::TabletDevice    This enum defines what type of device is generating the event.    \value NoDevice    No device, or an unknown device.    \value Puck    A Puck (a device that is similar to a flat mouse with    a transparent circle with cross-hairs).    \value Stylus  A Stylus.    \value Airbrush An airbrush    \value FourDMouse A 4D Mouse.    \value RotationStylus A special stylus that also knows about rotation           (a 6D stylus). \since 4.1    \omitvalue XFreeEraser*//*!    \enum QTabletEvent::PointerType    This enum defines what type of point is generating the event.    \value UnknownPointer    An unknown device.    \value Pen    Tip end of a stylus-like device (the narrow end of the pen).    \value Cursor  Any puck-like device.    \value Eraser  Eraser end of a stylus-like device (the broad end of the pen).    \sa pointerType()*//*!  Construct a tablet event of the given \a type.  The \a pos parameter indicates where the event occurred in the  widget; \a globalPos is the corresponding position in absolute  coordinates. The \a hiResGlobalPos contains a high resolution  measurement of the position.  \a pressure contains the pressure exerted on the \a device.  \a pointerType describes the type of pen that is being used.  \a xTilt and \a yTilt contain the device's degree of tilt from the  x and y axes respectively.  \a keyState specifies which keyboard modifiers are pressed (e.g.,  \key{Ctrl}).  The \a uniqueID parameter contains the unique ID for the current device.  The \a z parameter contains the coordinate of the device on the tablet, this  is usually given by a wheel on 4D mouse. If the device does not support a  Z-axis, pass zero here.  The \a tangentialPressure paramater contins the tangential pressure of an air  brush. If the device does not support tangential pressure, pass 0 here.  \a rotation contains the device's rotation in degrees. 4D mice support  rotation. If the device does not support rotation, pass 0 here.  \sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z()*/QTabletEvent::QTabletEvent(Type type, const QPoint &pos, const QPoint &globalPos,                           const QPointF &hiResGlobalPos, int device, int pointerType,                           qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,                           qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)    : QInputEvent(type, keyState),      mPos(pos),      mGPos(globalPos),      mHiResGlobalPos(hiResGlobalPos),      mDev(device),      mPointerType(pointerType),      mXT(xTilt),      mYT(yTilt),      mZ(z),      mPress(pressure),      mTangential(tangentialPressure),      mRot(rotation),      mUnique(uniqueID),      mExtra(0){}/*!    \internal*/QTabletEvent::~QTabletEvent(){}/*!    \fn TabletDevices QTabletEvent::device() const    Returns the type of device that generated the event.    This is useful if you want to know which end of a pen was used    to draw on the tablet.    \sa TabletDevice*//*!    \fn PointerType QTabletEvent::pointerType() const    Returns the type of point that generated the event.*//*!    \fn qreal QTabletEvent::tangentialPressure() const    Returns the tangential pressure for the device.  This is typically given by a finger    wheel on an airbrush tool.  The range is from -1.0 to 1.0. 0.0 indicates a    neutral position.  Current airbrushes can only move in the positive    direction from the neutrual position. If the device does not support    tangential pressure, this value is always 0.0.    \sa pressure()*//*!    \fn qreal QTabletEvent::rotation() const    Returns the rotation of the current device in degress. This is usually    given by a 4D Mouse. If the device doesn't support rotation this value is    always 0.0.*//*!    \fn qreal QTabletEvent::pressure() const    Returns the pressure for the device. 0.0 indicates that the stylus is not    on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.    \sa tangentialPressure()*//*!    \fn int QTabletEvent::xTilt() const    Returns the angle between the device (a pen, for example) and the    perpendicular in the direction of the x axis.    Positive values are towards the tablet's physical right. The angle    is in the range -60 to +60 degrees.    \img qtabletevent-tilt.png    \sa yTilt()*//*!    \fn int QTabletEvent::yTilt() const    Returns the angle between the device (a pen, for example) and the    perpendicular in the direction of the y axis.    Positive values are towards the bottom of the tablet. The angle is    within the range -60 to +60 degrees.    \sa xTilt()*//*!    \fn const QPoint &QTabletEvent::pos() const    Returns the position of the device, relative to the widget that    received the event.    If you move widgets around in response to mouse events, use    globalPos() instead of this function.    \sa x() y() globalPos()*//*!    \fn int QTabletEvent::x() const    Returns the x position of the device, relative to the widget that    received the event.    \sa y() pos()*//*!    \fn int QTabletEvent::y() const    Returns the y position of the device, relative to the widget that    received the event.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -