当前位置: 首页>>代码示例>>C++>>正文


C++ QWidget::activateWindow方法代码示例

本文整理汇总了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
}
开发者ID:demelziraptor,项目名称:tomahawk,代码行数:57,代码来源:TomahawkUtilsGui.cpp

示例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());
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例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());
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例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
}
开发者ID:AlekSi,项目名称:Jabbin,代码行数:33,代码来源:common.cpp

示例5: configureFilter

void MainWindow::configureFilter() {
  QWidget *widget = filter.settings();
  if(widget) {
    widget->show();
    widget->activateWindow();
    widget->raise();
  }
}
开发者ID:ben401,项目名称:OpenEmu,代码行数:8,代码来源:main.cpp

示例6: showAndActivate

void ConnectionPageWindowObject::showAndActivate()
{
    QWidget *widget = dynamic_cast<QWidget*>(this);
    Q_ASSERT(widget);

    widget->show();
    widget->activateWindow();
    widget->raise();
}
开发者ID:rovshan-b,项目名称:oraexp,代码行数:9,代码来源:connectionpagewindowobject.cpp

示例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();
}
开发者ID:loonuh,项目名称:Overflows,代码行数:13,代码来源:mem_pnl.cpp

示例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();
}
开发者ID:Swissbanker,项目名称:rstudio,代码行数:12,代码来源:DesktopMenuCallback.cpp

示例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();
    }
}
开发者ID:Andersbakken,项目名称:CPlusPlus,代码行数:12,代码来源:icore.cpp

示例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();
}
开发者ID:loonuh,项目名称:Overflows,代码行数:14,代码来源:mem_pnl.cpp

示例11: doAction

/*! \reimp */
bool QAccessibleApplication::doAction(int action, int child, const QVariantList &param)
{
    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);
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:15,代码来源:qaccessibleobject.cpp

示例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();
	}
}
开发者ID:apex-hughin,项目名称:LyX,代码行数:19,代码来源:Dialog.cpp

示例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) );
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:19,代码来源:Application.cpp

示例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;
}
开发者ID:B-Rich,项目名称:otter,代码行数:20,代码来源:SessionsManager.cpp

示例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();
}
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:39,代码来源:TabDropDock.cpp


注:本文中的QWidget::activateWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。