本文整理汇总了C++中QWindow::requestActivate方法的典型用法代码示例。如果您正苦于以下问题:C++ QWindow::requestActivate方法的具体用法?C++ QWindow::requestActivate怎么用?C++ QWindow::requestActivate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWindow
的用法示例。
在下文中一共展示了QWindow::requestActivate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleFocusEvent
/* Compress activation events. If the next focus window is already known
* at the time the current one receives focus-out, pass that to
* QWindowSystemInterface instead of sending 0 and ignore its consecutive
* focus-in event.
* This helps applications that do handling in focus-out events. */
void QWindowsContext::handleFocusEvent(QtWindows::WindowsEventType et,
QWindowsWindow *platformWindow)
{
QWindow *nextActiveWindow = 0;
if (et == QtWindows::FocusInEvent) {
QWindow *topWindow = QWindowsWindow::topLevelOf(platformWindow->window());
QWindow *modalWindow = 0;
if (QGuiApplicationPrivate::instance()->isWindowBlocked(topWindow, &modalWindow) && topWindow != modalWindow) {
modalWindow->requestActivate();
return;
}
// QTBUG-32867: Invoking WinAPI SetParent() can cause focus-in for the
// window which is not desired for native child widgets.
if (platformWindow->testFlag(QWindowsWindow::WithinSetParent)) {
QWindow *currentFocusWindow = QGuiApplication::focusWindow();
if (currentFocusWindow && currentFocusWindow != platformWindow->window()) {
currentFocusWindow->requestActivate();
return;
}
}
nextActiveWindow = platformWindow->window();
} else {
// Focus out: Is the next window known and different
// from the receiving the focus out.
if (const HWND nextActiveHwnd = GetFocus())
if (QWindowsWindow *nextActivePlatformWindow = findClosestPlatformWindow(nextActiveHwnd))
if (nextActivePlatformWindow != platformWindow)
nextActiveWindow = nextActivePlatformWindow->window();
}
if (nextActiveWindow != d->m_lastActiveWindow) {
d->m_lastActiveWindow = nextActiveWindow;
QWindowSystemInterface::handleWindowActivated(nextActiveWindow);
}
}
示例2: onOpenWindow
void Nexus::onOpenWindow(QObject* object)
{
QWindow* window = static_cast<QWindow*>(object);
if (window->windowState() & QWindow::Minimized)
window->showNormal();
window->raise();
window->requestActivate();
}
示例3: moveToForeground
void moveToForeground()
{
QWindowList l = QGuiApplication::allWindows();
if (l.size() > 0 && l.at(0) != nullptr) {
QWindow* w = l.at(0);
w->requestActivate();
if (w->windowState() & Qt::WindowMinimized) {
w->showNormal();
}
}
}
示例4: eventWindow
QWindow* TestService::eventWindow(QObject* _item)
{
QQuickItem* item = qobject_cast<QQuickItem*>(_item);
if (item && item->window())
return item->window();
QWindow* window = qobject_cast<QQuickWindow*>(_item);
if (!window && _item->parent())
window = eventWindow(_item->parent());
if (!window)
window = qobject_cast<QQuickWindow*>(m_targetWindow);
if (window)
{
window->requestActivate();
std::cout << window->title().toStdString();
return window;
}
item = qobject_cast<QQuickItem*>(m_targetWindow);
if (item)
return item->window();
return 0;
}
示例5: testActivation
void tst_QWindowContainer::testActivation()
{
QWidget root;
QWindow *window = new QWindow();
QWidget *container = QWidget::createWindowContainer(window, &root);
container->setGeometry(100, 100, 200, 100);
root.setGeometry(100, 100, 400, 300);
root.show();
root.activateWindow();
QVERIFY(QTest::qWaitForWindowExposed(&root));
QVERIFY(QTest::qWaitForWindowActive(root.windowHandle()));
QVERIFY(QGuiApplication::focusWindow() == root.windowHandle());
// Verify that all states in the root widget indicate it is active
QVERIFY(root.windowHandle()->isActive());
QVERIFY(root.isActiveWindow());
QCOMPARE(root.palette().currentColorGroup(), QPalette::Active);
// Under KDE (ubuntu 12.10), we experience that doing two activateWindow in a row
// does not work. The second gets ignored by the window manager, even though the
// timestamp in the xcb connection is unique for both.
if (QGuiApplication::platformName() == "xcb")
QTest::qWait(100);
window->requestActivate();
QTRY_VERIFY(QGuiApplication::focusWindow() == window);
// Verify that all states in the root widget still indicate it is active
QVERIFY(root.windowHandle()->isActive());
QVERIFY(root.isActiveWindow());
QCOMPARE(root.palette().currentColorGroup(), QPalette::Active);
}