本文整理汇总了C++中QWindow::mapToGlobal方法的典型用法代码示例。如果您正苦于以下问题:C++ QWindow::mapToGlobal方法的具体用法?C++ QWindow::mapToGlobal怎么用?C++ QWindow::mapToGlobal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWindow
的用法示例。
在下文中一共展示了QWindow::mapToGlobal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showText
void ToolTip::showText(QQuickItem *item, const QPointF &pos, const QString &str) {
QPoint quickWidgetOffsetInTlw;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
QWindow *renderWindow = QQuickRenderControl::renderWindowFor(item->window(), &quickWidgetOffsetInTlw);
QWindow *window = renderWindow ? renderWindow : item->window();
#else
QWindow *window = item->window();
#endif
const QPoint offsetInQuickWidget = item->mapToScene(pos).toPoint();
const QPoint mappedPos = window->mapToGlobal(offsetInQuickWidget + quickWidgetOffsetInTlw);
QToolTip::showText(mappedPos, str);
}
示例2: mapToGlobal
QPoint QWidget::mapToGlobal(const QPoint &pos) const
{
int x = pos.x(), y = pos.y();
const QWidget *w = this;
while (w) {
QWindow *window = w->windowHandle();
if (window && window->handle())
return window->mapToGlobal(QPoint(x, y));
x += w->data->crect.x();
y += w->data->crect.y();
w = w->isWindow() ? 0 : w->parentWidget();
}
return QPoint(x, y);
}
示例3: update
void QMeeGoPlatformInputContext::update(Qt::InputMethodQueries queries)
{
QInputPanel *panel = qApp->inputPanel();
QObject *input = panel->inputItem();
if (!input)
return;
QInputMethodQueryEvent query(queries);
QGuiApplication::sendEvent(input, &query);
if (queries & Qt::ImSurroundingText)
d->imState["surroundingText"] = query.value(Qt::ImSurroundingText);
if (queries & Qt::ImCursorPosition)
d->imState["cursorPosition"] = query.value(Qt::ImCursorPosition);
if (queries & Qt::ImAnchorPosition)
d->imState["anchorPosition"] = query.value(Qt::ImAnchorPosition);
if (queries & Qt::ImCursorRectangle) {
QRect rect = query.value(Qt::ImCursorRectangle).toRect();
rect = panel->inputItemTransform().mapRect(rect);
QWindow *window = panel->inputWindow();
if (window)
d->imState["cursorRectangle"] = QRect(window->mapToGlobal(rect.topLeft()), rect.size());
}
if (queries & Qt::ImCurrentSelection)
d->imState["hasSelection"] = !query.value(Qt::ImCurrentSelection).toString().isEmpty();
if (queries & Qt::ImHints) {
Qt::InputMethodHints hints = Qt::InputMethodHints(query.value(Qt::ImHints).toUInt());
d->imState["predictionEnabled"] = !(hints & Qt::ImhNoPredictiveText);
d->imState["autocapitalizationEnabled"] = !(hints & Qt::ImhNoAutoUppercase);
d->imState["hiddenText"] = (hints & Qt::ImhHiddenText) != 0;
d->imState["contentType"] = contentTypeFromHints(hints);
}
d->sendStateUpdate(/*focusChanged*/true);
}
示例4: handleMouseEvent
void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
{
static const QEvent::Type contextMenuTrigger =
QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool() ?
QEvent::MouseButtonRelease : QEvent::MouseButtonPress;
if (qApp->d_func()->inPopupMode()) {
QWidget *activePopupWidget = qApp->activePopupWidget();
QWidget *popup = activePopupWidget;
QPoint mapped = event->pos();
if (popup != m_widget)
mapped = popup->mapFromGlobal(event->globalPos());
bool releaseAfter = false;
QWidget *popupChild = popup->childAt(mapped);
if (popup != qt_popup_down) {
qt_button_down = 0;
qt_popup_down = 0;
}
switch (event->type()) {
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
qt_button_down = popupChild;
qt_popup_down = popup;
break;
case QEvent::MouseButtonRelease:
releaseAfter = true;
break;
default:
break; // nothing for mouse move
}
int oldOpenPopupCount = openPopupCount;
if (popup->isEnabled()) {
// deliver event
qt_replay_popup_mouse_event = false;
QWidget *receiver = popup;
QPoint widgetPos = mapped;
if (qt_button_down)
receiver = qt_button_down;
else if (popupChild)
receiver = popupChild;
if (receiver != popup)
widgetPos = receiver->mapFromGlobal(event->globalPos());
QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos()));
QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers());
QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event));
e.setTimestamp(event->timestamp());
QApplicationPrivate::sendMouseEvent(receiver, &e, alien, m_widget, &qt_button_down, qt_last_mouse_receiver);
qt_last_mouse_receiver = receiver;
} else {
// close disabled popups when a mouse button is pressed or released
switch (event->type()) {
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
popup->close();
break;
default:
break;
}
}
if (qApp->activePopupWidget() != activePopupWidget
&& qt_replay_popup_mouse_event
&& QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) {
if (m_widget->windowType() != Qt::Popup)
qt_button_down = 0;
if (event->type() == QEvent::MouseButtonPress) {
// the popup disappeared, replay the mouse press event
QWidget *w = QApplication::widgetAt(event->globalPos());
if (w && !QApplicationPrivate::isBlockedByModal(w)) {
// activate window of the widget under mouse pointer
if (!w->isActiveWindow()) {
w->activateWindow();
w->raise();
}
QWindow *win = w->windowHandle();
if (!win)
win = w->nativeParentWidget()->windowHandle();
if (win) {
const QRect globalGeometry = win->isTopLevel()
? win->geometry()
: QRect(win->mapToGlobal(QPoint(0, 0)), win->size());
if (globalGeometry.contains(event->globalPos())) {
// Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
const QPoint localPos = win->mapFromGlobal(event->globalPos());
QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
QCoreApplicationPrivate::setEventSpontaneous(e, true);
QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
e->setTimestamp(event->timestamp());
QCoreApplication::postEvent(win, e);
}
}
}
}
qt_replay_popup_mouse_event = false;
#ifndef QT_NO_CONTEXTMENU
//.........这里部分代码省略.........