本文整理汇总了C++中QWidget::activateWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::activateWindow方法的具体用法?C++ QWidget::activateWindow怎么用?C++ QWidget::activateWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::activateWindow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
void
bringToFront()
{
#if defined(Q_WS_X11)
{
qDebug() << Q_FUNC_INFO;
QWidget* widget = tomahawkWindow();
if ( !widget )
return;
widget->show();
widget->activateWindow();
widget->raise();
WId wid = widget->winId();
NETWM::init();
XEvent e;
e.xclient.type = ClientMessage;
e.xclient.message_type = NETWM::NET_ACTIVE_WINDOW;
e.xclient.display = QX11Info::display();
e.xclient.window = wid;
e.xclient.format = 32;
e.xclient.data.l[0] = 2;
e.xclient.data.l[1] = QX11Info::appTime();
e.xclient.data.l[2] = 0;
e.xclient.data.l[3] = 0l;
e.xclient.data.l[4] = 0l;
XSendEvent( QX11Info::display(), RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) ), False, SubstructureRedirectMask | SubstructureNotifyMask, &e );
}
#elif defined(Q_WS_WIN)
{
qDebug() << Q_FUNC_INFO;
QWidget* widget = tomahawkWindow();
if ( !widget )
return;
widget->show();
widget->activateWindow();
widget->raise();
WId wid = widget->winId();
HWND hwndActiveWin = GetForegroundWindow();
int idActive = GetWindowThreadProcessId(hwndActiveWin, NULL);
if ( AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) )
{
SetForegroundWindow( wid );
SetFocus( wid );
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
}
}
#endif
}
示例2: edit
void tst_QRadioButton::task190739_focus()
{
QWidget widget;
QPushButton button1(&widget);
button1.setText("button1");
QLineEdit edit(&widget);
edit.setFocus();
QRadioButton radio1(&widget);
radio1.setText("radio1");
radio1.setFocusPolicy(Qt::TabFocus);
radio1.setShortcut(QKeySequence("Ctrl+O"));
QVBoxLayout layout(&widget);
layout.addWidget(&button1);
layout.addWidget(&edit);
layout.addWidget(&radio1);
widget.show();
widget.activateWindow();
QApplication::setActiveWindow(&widget);
QTest::qWait(100);
QVERIFY(edit.hasFocus());
QVERIFY(!radio1.isChecked());
QTest::keyClick(&edit, Qt::Key_O, Qt::ControlModifier, 20);
QTest::qWait(200);
QVERIFY(radio1.isChecked());
QVERIFY(edit.hasFocus());
QVERIFY(!radio1.hasFocus());
}
示例3: tearOff
void tst_QMenu::tearOff()
{
QWidget widget;
QMenu *menu = new QMenu(&widget);
QVERIFY(!menu->isTearOffEnabled()); //default value
menu->setTearOffEnabled(true);
menu->addAction("aaa");
menu->addAction("bbb");
QVERIFY(menu->isTearOffEnabled());
widget.show();
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
menu->popup(QPoint(0,0));
QVERIFY(QTest::qWaitForWindowActive(menu));
QVERIFY(!menu->isTearOffMenuVisible());
QTest::mouseClick(menu, Qt::LeftButton, 0, QPoint(3, 3), 10);
QTRY_VERIFY(menu->isTearOffMenuVisible());
QPointer<QMenu> torn = 0;
foreach (QWidget *w, QApplication::allWidgets()) {
if (w->inherits("QTornOffMenu")) {
torn = static_cast<QMenu *>(w);
break;
}
}
QVERIFY(torn);
QVERIFY(torn->isVisible());
menu->hideTearOffMenu();
QVERIFY(!menu->isTearOffMenuVisible());
QVERIFY(!torn->isVisible());
}
示例4: bringToFront
void bringToFront(QWidget *widget, bool)
{
Q_ASSERT(widget);
QWidget* w = widget->window();
#ifdef Q_WS_X11
// If we're not on the current desktop, do the hide/show trick
long dsk, curr_dsk;
Window win = w->winId();
if(desktopOfWindow(&win, &dsk) && currentDesktop(&curr_dsk)) {
if((dsk != curr_dsk) && (dsk != -1)) { // second condition for sticky windows
w->hide();
}
}
// FIXME: multi-desktop hacks for Win and Mac required
#endif
if(w->isMaximized())
w->showMaximized();
else
w->showNormal();
//if(grabFocus)
// w->setActiveWindow();
w->raise();
w->activateWindow();
#ifdef Q_WS_WIN
// TODO: unify with AdvancedWidget::bringToFront()
ForceForegroundWindow(w->winId());
#endif
}
示例5: configureFilter
void MainWindow::configureFilter() {
QWidget *widget = filter.settings();
if(widget) {
widget->show();
widget->activateWindow();
widget->raise();
}
}
示例6: showAndActivate
void ConnectionPageWindowObject::showAndActivate()
{
QWidget *widget = dynamic_cast<QWidget*>(this);
Q_ASSERT(widget);
widget->show();
widget->activateWindow();
widget->raise();
}
示例7: editData
//-----------------------------------------------------------------------------
void MemPanel::editData(int n)
{
if(tab->rowCount()<1) return;
if(n<0) n = tab->currentRow();
if(n<0) n = 0;
mglDataA *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str());
if(!v) return;
QWidget *t;
if(v->o) t = (QWidget *)v->o;
else t = newDataWnd(infoDlg,wnd,v);
t->showMaximized(); t->activateWindow();
}
示例8: showWindow
void WindowMenu::showWindow()
{
QAction* pAction = qobject_cast<QAction*>(sender());
if (!pAction)
return;
QWidget* pWidget = pAction->data().value<QWidget*>();
if (!pWidget)
return;
if (pWidget->isMinimized())
pWidget->setWindowState(pWidget->windowState() & ~Qt::WindowMinimized);
pWidget->activateWindow();
}
示例9: raiseWindow
void ICore::raiseWindow(QWidget *widget)
{
if (!widget)
return;
QWidget *window = widget->window();
if (window == m_mainwindow) {
m_mainwindow->raiseWindow();
} else {
window->raise();
window->activateWindow();
}
}
示例10: newTable
//-----------------------------------------------------------------------------
void MemPanel::newTable()
{
bool ok;
QString name = QInputDialog::getText(this, tr("UDAV - New variable"),
tr("Enter name for new variable"), QLineEdit::Normal, "", &ok);
if(!ok || name.isEmpty()) return;
mglData *v = parser.AddVar(name.toStdString().c_str());
QWidget *t;
if(v->o) t = (QWidget *)v->o;
else t = newDataWnd(infoDlg,wnd,v);
t->showMaximized(); t->activateWindow();
refresh();
}
示例11: doAction
/*! \reimp */
bool QAccessibleApplication::doAction(int action, int child, const QVariantList ¶m)
{
if (action == 0 || action == 1) {
QWidget *w = 0;
w = QApplication::activeWindow();
if (!w)
w = topLevelWidgets().at(0);
if (!w)
return false;
w->activateWindow();
return true;
}
return QAccessibleObject::doAction(action, child, param);
}
示例12: showView
void Dialog::showView()
{
prepareView();
QWidget * w = asQWidget();
if (w->isVisible()) {
w->raise();
w->activateWindow();
} else
w->show();
if (wantInitialFocus())
w->setFocus();
else {
lyxview_->raise();
lyxview_->activateWindow();
lyxview_->setFocus();
}
}
示例13: parseArgs
void Application::parseArgs( const QStringList &args )
{
QStringList params = args;
params.removeAll("-capi");
params.removeAll("-cng");
params.removeAll("-pkcs11");
params.removeAll("-noNativeFileDialog");
QWidget *w = new MainWindow();
#ifdef Q_OS_MAC
w->installEventFilter( d->bar );
#endif
w->addAction( d->closeAction );
w->activateWindow();
w->show();
w->raise();
if( !params.isEmpty() )
QMetaObject::invokeMethod( w, "open", Q_ARG(QStringList,params) );
}
示例14: hasUrl
bool SessionsManager::hasUrl(const QUrl &url, bool activate)
{
for (int i = 0; i < m_managers.count(); ++i)
{
if (m_managers.at(i)->hasUrl(url, activate))
{
QWidget *window = qobject_cast<QWidget*>(m_managers.at(i)->parent());
if (window)
{
window->raise();
window->activateWindow();
}
return true;
}
}
return false;
}
示例15: mousePressEvent
/*
void TabDropDock::mousePressEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton) m_startDragPos = e->pos();
}
void TabDropDock::mouseMoveEvent(QMouseEvent *e)
{
if (e->buttons() & Qt::LeftButton)
{
int distance = (e->pos() - m_startDragPos).manhattanLength();
if (distance >= QApplication::startDragDistance()) performDrag();
}
}
*/
void TabDropDock::slotPerformDrag()
{
// emit(signalFloatOrDockMe(this));
QDrag *drag = new QDrag(this);
QWidget *widget = currentWidget();
if (widget)
{
WidgetMimeData *mimeData = new WidgetMimeData(widget);
drag->setMimeData(mimeData);
if (drag->exec(Qt::MoveAction) != Qt::MoveAction)
{
if (widget->parent() != 0)
{
widget->setParent(0);
widget->setGeometry(QCursor::pos().x(),QCursor::pos().y(),width(),height());
widget->show();
widget->raise();
widget->activateWindow();
// removeTab(currentIndex());
}
}
}
// this->repaint();
}