• 9609阅读
  • 7回复

当tcpServer收到信息时,我想使界面跳出来,显示到最前端,如何做到? [复制链接]

上一主题 下一主题
离线conta
 
只看楼主 正序阅读 楼主  发表于: 2010-10-23
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
注意,不是设置为"总在前端"模式,而只是收到信息的一刻,使得窗体在其它应用程序的前面即可.

注意:信号槽触发我已经写好。

不知道是使用窗体的哪一个函数?


show(),showNormal()这些函数,都不能使得窗体移动到最前端来显示。。。



离线yanzhuliang

只看该作者 7楼 发表于: 2010-11-01
在构造窗口时,设置一下窗口风格QWidget::setWindowFlags ( Qt::WindowStaysOnTopHint ),也许这样可以哦
离线benbenmajia

只看该作者 6楼 发表于: 2010-11-01
回 5楼(在梅边) 的帖子
怎么个多个应用程序法?
安然.....
离线在梅边
只看该作者 5楼 发表于: 2010-10-30
只知道如果是同一个应用程序之间窗口切换使用raise()就可以了
如果是多个应用程序,LS的方法可以吧
离线XChinux

只看该作者 4楼 发表于: 2010-10-23
没做过其他平台的,就说windows下吧,先激活当前应用的主窗口,然后再将你的窗口在最前面(本应用中)显示出来,比如下面的代码:


#ifdef Q_WS_WIN
    SetForegroundWindow(winId());
#endif
    Qt::WindowStates flags = windowState();
    if (qApp->activeWindow() == this)
    {
    }
    else if (!flags.testFlag(Qt::WindowMinimized))
    {
        showMinimized();  // 在这里必须先最小化,否则直接调用showMaximized()可能并不能显示到最前面去。
    }
    showMaximized(); // or show();
    // 在这里显示自己的label窗口。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线conta
只看该作者 3楼 发表于: 2010-10-23
有没有其它办法?
现在的情况是:
跳时跳出来了,只不过,还是被其它应用程序的窗体遮住了...
离线conta
只看该作者 2楼 发表于: 2010-10-23
引用第1楼dbzhang800于2010-10-23 15:39发表的  :
On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way. This is because Microsoft does not allow an application to interrupt what the user is currently doing in another application.



这里不是说清楚了,在windows平台上,activeWindows函数不能实现这个功能了吗?
离线dbzhang800

只看该作者 1楼 发表于: 2010-10-23
void QWidget::activateWindow ()
Sets the top-level widget containing this widget to be the active window.
An active window is a visible top-level window that has the keyboard input focus.
This function performs the same operation as clicking the mouse on the title bar of a top-level window. On X11, the result depends on the Window Manager. If you want to ensure that the window is stacked on top as well you should also call raise(). Note that the window must be visible, otherwise activateWindow() has no effect.
On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way. This is because Microsoft does not allow an application to interrupt what the user is currently doing in another application.
快速回复
限100 字节
 
上一个 下一个