本文整理汇总了C++中QWidget::inputMethodQuery方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::inputMethodQuery方法的具体用法?C++ QWidget::inputMethodQuery怎么用?C++ QWidget::inputMethodQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::inputMethodQuery方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleContextMenuEvent
void QWidgetWindow::handleContextMenuEvent(QContextMenuEvent *e)
{
// We are only interested in keyboard originating context menu events here,
// mouse originated context menu events for widgets are generated in mouse handling methods.
if (e->reason() != QContextMenuEvent::Keyboard)
return;
QWidget *fw = QWidget::keyboardGrabber();
if (!fw) {
if (QApplication::activePopupWidget()) {
fw = (QApplication::activePopupWidget()->focusWidget()
? QApplication::activePopupWidget()->focusWidget()
: QApplication::activePopupWidget());
} else if (QApplication::focusWidget()) {
fw = QApplication::focusWidget();
} else {
fw = m_widget;
}
}
if (fw && fw->isEnabled()) {
QPoint pos = fw->inputMethodQuery(Qt::ImMicroFocus).toRect().center();
QContextMenuEvent widgetEvent(QContextMenuEvent::Keyboard, pos, fw->mapToGlobal(pos),
e->modifiers());
QGuiApplication::sendSpontaneousEvent(fw, &widgetEvent);
}
}
示例2: mouseHandler
void MInputContext::mouseHandler(int x, QMouseEvent *event)
{
Q_UNUSED(x);
qDebug() << "MInputContext" << "in" << __PRETTY_FUNCTION__;
qDebug() << "MInputContext" << " event pos: " << event->globalPos() << " cursor pos:" << x;
if (event->type() == QEvent::MouseButtonPress && (x < 0 || x > preedit.length())) {
reset();
return;
}
// input method server needs to be informed about clicks
if (event->type() == QEvent::MouseButtonRelease && x >= 0) {
// Query preedit rectangle and pass it to im server if found.
// In case of plain QT application, null rectangle will be passed.
QWidget *focused = focusWidget();
QRect preeditRect;
#ifdef HAVE_MEEGOTOUCH
if (focused) {
// TODO: Move M::PreeditRectangleQuery to MInputMethod
Qt::InputMethodQuery query
= static_cast<Qt::InputMethodQuery>(M::PreeditRectangleQuery);
preeditRect = focused->inputMethodQuery(query).toRect();
}
#else
Q_UNUSED(focused);
#endif
imServer->mouseClickedOnPreedit(event->globalPos(), preeditRect);
}
}
示例3: inputMethodQuery
/*!
\internal
Reimplemented from QGraphicsItemPrivate. ### Qt 5: Move impl to
reimplementation QGraphicsProxyWidget::inputMethodQuery().
*/
QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
{
Q_Q(const QGraphicsProxyWidget);
if (!widget || !q->hasFocus())
return QVariant();
QWidget *focusWidget = widget->focusWidget();
if (!focusWidget)
focusWidget = widget;
QVariant v = focusWidget->inputMethodQuery(query);
QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
switch (v.type()) {
case QVariant::RectF:
v = v.toRectF().translated(focusWidgetPos);
break;
case QVariant::PointF:
v = v.toPointF() + focusWidgetPos;
break;
case QVariant::Rect:
v = v.toRect().translated(focusWidgetPos.toPoint());
break;
case QVariant::Point:
v = v.toPoint() + focusWidgetPos.toPoint();
break;
default:
break;
}
return v;
}
示例4: inputMethodQuery
QVariant QWidgetProto::inputMethodQuery(int query) const
{
QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
if (item)
return item->inputMethodQuery((Qt::InputMethodQuery)query);
return QVariant();
}
示例5: focusWidget
void
IBusInputContext::update ()
{
QWidget *widget = focusWidget ();
if (widget == NULL) {
return;
}
QRect rect = widget->inputMethodQuery(Qt::ImMicroFocus).toRect ();
QPoint topleft = widget->mapToGlobal(QPoint(0,0));
rect.translate (topleft);
client->setCursorLocation (this, rect);
#if 0
QVariant value;
qDebug () << "== update == ";
value = widget->inputMethodQuery(Qt::ImMicroFocus);
qDebug () << "Qt::ImMicroFocus " << value;
value = widget->inputMethodQuery(Qt::ImFont);
qDebug () << "Qt::ImFont " <<value;
value = widget->inputMethodQuery(Qt::ImCursorPosition);
qDebug () << "Qt::ImCursorPosition " << value;
value = widget->inputMethodQuery(Qt::ImSurroundingText);
qDebug () << "Qt::ImSurroundingText " << value;
value = widget->inputMethodQuery(Qt::ImCurrentSelection);
qDebug () << "Qt::ImCurrentSelection " << value;
#endif
}
示例6: QVERIFY
void tst_QScrollArea::ensureMicroFocusVisible_Task_167838()
{
QScrollArea scrollArea;
scrollArea.resize(100, 100);
scrollArea.show();
QWidget *parent = new QWidget;
parent->setLayout(new QVBoxLayout);
QWidget *child = new WidgetWithMicroFocus;
parent->layout()->addWidget(child);
parent->resize(300, 300);
scrollArea.setWidget(parent);
scrollArea.ensureWidgetVisible(child, 10, 10);
QRect microFocus = child->inputMethodQuery(Qt::ImMicroFocus).toRect();
QPoint p = child->mapTo(scrollArea.viewport(), microFocus.topLeft());
microFocus.translate(p - microFocus.topLeft());
QVERIFY(scrollArea.viewport()->rect().contains(microFocus));
}
示例7: eventFilter
bool CandidateWindowProxy::eventFilter(QObject *obj, QEvent *event)
{
if (obj == window) {
if (event->type() == QEvent::Move) {
QWidget *widget = QApplication::focusWidget();
if (widget) {
QRect rect
= widget->inputMethodQuery(Qt::ImMicroFocus).toRect();
QPoint p = widget->mapToGlobal(rect.topLeft());
layoutWindow(p.x(), p.y(), rect.height());
} else {
QMoveEvent *moveEvent = static_cast<QMoveEvent *>(event);
QPoint p = moveEvent->pos() - moveEvent->oldPos();
execute("move_candwin\f" + QString::number(p.x()) + '\f'
+ QString::number(p.y()));
}
}
return false;
}
return QObject::eventFilter(obj, event);
}
示例8: popupCandidateList
bool QHangulPlatformInputContext::popupCandidateList() {
const ucschar *text = hangul_ic_get_preedit_string(m_hic);
if (text != NULL && *text != 0) {
QString str;
str += QChar(text[0]);
HanjaList *list = hanja_table_match_suffix(hanjaTable, str.toUtf8());
if (m_candidateList == NULL)
m_candidateList = new CandidateList();
QPoint p(0, 0);
QWidget *focus = qobject_cast<QWidget *>(m_focusObject);
if (focus != NULL) {
QVariant v = focus->inputMethodQuery(Qt::ImMicroFocus);
QRect r = v.toRect();
p = focus->mapToGlobal(QPoint(r.right(), r.bottom()));
}
m_candidateList->open(list, p.x(), p.y());
}
return false;
}
示例9: loopLevelCounter
OSStatus
QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void *)
{
#ifndef QT_MAC_USE_COCOA
QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData);
SRefCon refcon = 0;
GetEventParameter(event, kEventParamTextInputSendRefCon, typeRefCon, 0,
sizeof(refcon), 0, &refcon);
QMacInputContext *context = reinterpret_cast<QMacInputContext*>(refcon);
bool handled_event=true;
UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
switch(eclass) {
case kEventClassTextInput: {
handled_event = false;
QWidget *widget = QApplicationPrivate::focus_widget;
bool canCompose = widget && (!context || widget->inputContext() == context)
&& !(widget->inputMethodHints() & Qt::ImhDigitsOnly
|| widget->inputMethodHints() & Qt::ImhFormattedNumbersOnly
|| widget->inputMethodHints() & Qt::ImhHiddenText);
if(!canCompose) {
handled_event = false;
} else if(ekind == kEventTextInputOffsetToPos) {
if(!widget->testAttribute(Qt::WA_InputMethodEnabled)) {
handled_event = false;
break;
}
QRect mr(widget->inputMethodQuery(Qt::ImMicroFocus).toRect());
QPoint mp(widget->mapToGlobal(QPoint(mr.topLeft())));
Point pt;
pt.h = mp.x();
pt.v = mp.y() + mr.height();
SetEventParameter(event, kEventParamTextInputReplyPoint, typeQDPoint,
sizeof(pt), &pt);
handled_event = true;
} else if(ekind == kEventTextInputUpdateActiveInputArea) {
if(!widget->testAttribute(Qt::WA_InputMethodEnabled)) {
handled_event = false;
break;
}
if (context->recursionGuard)
break;
ByteCount unilen = 0;
GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
0, 0, &unilen, 0);
UniChar *unicode = (UniChar*)NewPtr(unilen);
GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
0, unilen, 0, unicode);
QString text((QChar*)unicode, unilen / sizeof(UniChar));
DisposePtr((char*)unicode);
ByteCount fixed_length = 0;
GetEventParameter(event, kEventParamTextInputSendFixLen, typeByteCount, 0,
sizeof(fixed_length), 0, &fixed_length);
if(fixed_length == ULONG_MAX || fixed_length == unilen) {
QInputMethodEvent e;
e.setCommitString(text);
context->currentText = QString();
qt_sendSpontaneousEvent(context->focusWidget(), &e);
handled_event = true;
context->reset();
} else {
ByteCount rngSize = 0;
OSStatus err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
0, &rngSize, 0);
QVarLengthArray<TextRangeArray> highlight(rngSize);
if (noErr == err) {
err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
rngSize, &rngSize, highlight.data());
}
context->composing = true;
if(fixed_length > 0) {
const int qFixedLength = fixed_length / sizeof(UniChar);
QList<QInputMethodEvent::Attribute> attrs;
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
qFixedLength, text.length()-qFixedLength,
qt_mac_compose_format());
QInputMethodEvent e(text, attrs);
context->currentText = text;
e.setCommitString(text.left(qFixedLength), 0, qFixedLength);
qt_sendSpontaneousEvent(widget, &e);
handled_event = true;
} else {
/* Apple's enums that they have removed from Tiger :(
enum {
kCaretPosition = 1,
kRawText = 2,
kSelectedRawText = 3,
kConvertedText = 4,
kSelectedConvertedText = 5,
kBlockFillText = 6,
kOutlineText = 7,
kSelectedText = 8
};
*/
#ifndef kConvertedText
//.........这里部分代码省略.........