如何使程序在任务栏上变色闪动

bingshanzhiling 2011-04-07 11:18:14
类似于QQ和msn来消息后会在屏幕的正下方一闪一闪的。变亮
但窗口不弹出来。
...全文
383 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
bingshanzhiling 2011-04-08
  • 打赏
  • 举报
回复
就是个严重的悲剧
后来自己找到了,用QApplication::alert()

Causes an alert to be shown for widget if the window is not the active window. The alert is shown for msec miliseconds. If msec is zero (the default), then the alert is shown indefinitely until the window becomes active again.
Currently this function does nothing on Qt for Embedded Linux.
On Mac OS X, this works more at the application level and will cause the application icon to bounce in the dock.
On Windows, this causes the window's taskbar entry to flash for a time. If msec is zero, the flashing will stop and the taskbar entry will turn a different color (currently orange).
On X11, this will cause the window to be marked as "demands attention", the window must not be hidden (i.e. not have hide() called on it, but be visible in some sort of way) in order for this to work.
This function was introduced in Qt 4.3.
dbzhang800 2011-04-07
  • 打赏
  • 举报
回复
[Quote=引用楼主 bingshanzhiling 的回复:]
类似于QQ和msn来消息后会在屏幕的正下方一闪一闪的。变亮
但窗口不弹出来。
[/Quote]
多看看manual:

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.
念茜 2011-04-07
  • 打赏
  • 举报
回复
statusbar
dbzhang800 2011-04-07
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 bingshanzhiling 的回复:]

引用 4 楼 paulqingxue 的回复:

我看了一下二楼的解释,好像和楼主的要求不一样
楼主是要的右下角跳动企鹅的效果
而二楼说的是任务栏的activewindow



效果是二楼的。。。但是还没有搞出来。。。
[/Quote]
一个测试例子:


from PySide import QtCore, QtGui

class Widget(QtGui.QWidget):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
self.resize(300, 200)
QtCore.QTimer.singleShot(6000, self.activateWindow)

if __name__=="__main__":
import sys
app = QtGui.QApplication(sys.argv)
w = Widget()
w.showMinimized()
sys.exit(app.exec_())
bingshanzhiling 2011-04-07
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 paulqingxue 的回复:]

我看了一下二楼的解释,好像和楼主的要求不一样
楼主是要的右下角跳动企鹅的效果
而二楼说的是任务栏的activewindow
[/Quote]


效果是二楼的。。。但是还没有搞出来。。。
dbzhang800 2011-04-07
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 paulqingxue 的回复:]

我看了一下二楼的解释,好像和楼主的要求不一样
楼主是要的右下角跳动企鹅的效果
而二楼说的是任务栏的activewindow
[/Quote]
这样的话,
只能让楼主进一步解释意图了,如果是指通知栏的图标,应该加个定时器定时切换就够了吧?
paulqingxue 2011-04-07
  • 打赏
  • 举报
回复
我看了一下二楼的解释,好像和楼主的要求不一样
楼主是要的右下角跳动企鹅的效果
而二楼说的是任务栏的activewindow
paulqingxue 2011-04-07
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 dbzhang800 的回复:]

引用楼主 bingshanzhiling 的回复:
类似于QQ和msn来消息后会在屏幕的正下方一闪一闪的。变亮
但窗口不弹出来。

多看看manual:

void QWidget::activateWindow ()
Sets the top-level widget containing this widget to be the active window.
An acti……
[/Quote]

受教了,请问这个是msdn上的吗?

16,238

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧