【发布时间】:2014-07-09 13:33:58
【问题描述】:
我正在尝试将 QSplashScreen 用作“简单”通知窗口。我在一个对话框中构建了实际的通知,然后尝试在其上使用 QPixmap.grabWidget() 并将像素图传递给 SplashScreen 但它没有显示。所以我想知道问题是否是由于我试图在启动后使用它。
我正在做的事情的简化版。
class NotifyHandler:
def showNotify(self, event):
widget = NotifyWidget.createInstance(event) # Build the QDialog
#Do I need to do widget.show()?
pixmap = QtGui.QPixmap.grabWidget(widget) # Convert to pixmap
splash = QtGui.QSplashScreen(pixmap, QtCore.Qt.WindowStayOnTopHint)
(x,y) = getDisplayLocation(splash) # Get coords to put it in bottom-right corner
splash.setGeometry(splash.width(), splash.height(), x, y)
splash.show()
QtCore.QTimer.singleShot(3000, splash.close)
我尝试了这个,但没有任何显示。如果我尝试将其作为对话框:
widget.show()
widget.raise_()
widget.activateWindow()
它工作正常。所以我想要么我不能在发布后执行此操作,要么当我尝试向它提供一个小部件的像素图时发生了一些事情。有什么想法吗?
【问题讨论】:
-
从头开始。该对话框不再正常显示。所以也许我的问题出在某个地方。
-
也值得注意以备将来参考。我的 setGeometry 是向后的,它的 x,y,w,h。