Python qsplashsscreen.setPixmap将飞溅屏幕移回默认位置

Python qsplashsscreen.setPixmap将飞溅屏幕移回默认位置,python,qt5,pyqt5,qpixmap,qsplashscreen,Python,Qt5,Pyqt5,Qpixmap,Qsplashscreen,我使用创建了一个,并将其移动到第二个监视器的中心,而不是默认监视器: class SplashScreen(QSplashScreen): def __init__(self): self._pixmap = QPixmap("test1.png") super(SplashScreen, self).__init__(self._pixmap) screen = 1 scr = qApp.desktop().screenGeometry(screen)

我使用创建了一个,并将其移动到第二个监视器的中心,而不是默认监视器:

class SplashScreen(QSplashScreen):
  def __init__(self):
    self._pixmap = QPixmap("test1.png")
    super(SplashScreen, self).__init__(self._pixmap)

    screen = 1
    scr = qApp.desktop().screenGeometry(screen)
    self.move(scr.center() - self.rect().center()) # move to second screen
我现在正试图在SplashScreen显示时向我的pixmap添加一些内容:

  def drawSomething(self):
    add = QPixmap('test2.png')
    painter = QPainter(self._pixmap)
    painter.drawPixmap(0,0, add)
    #nothing happing so far
    self.repaint() # nothing happening
    self.setPixmap(self._pixmap) # changes shown, but moved back to default-screen
似乎用于创建QSplashScreen的QPixmap已被复制,不再是相同的引用,因此对此的更改没有直接影响

此外,使用将飞溅屏幕移回到默认监视器上

是否有一个选项可以直接在Splashscreen的活动QPixmap上绘制,或者设置一个新的,而无需再次移动屏幕

使用move命令似乎不是一个好的选择,当您在短时间内快速重新绘制时,splashscreen会在两个监视器上闪烁

用法示例:

app = QApplication([])
splash = SplashScreen()
splash.show()
splash.drawSomething()
exit(app.exec_())

您应该重新实现该功能以在QSplashScreen QPixmap上执行绘制。

我终于成功地使用QPainter on self重新实现了:

然而,重新实现功能也很好:

def drawContents(self, painter):
    painter.drawPixmap(0,0, QPixmap('test2.png'))
    super(SplashScreen, self).drawContents(painter)
请记住,在完成绘画后,也要呼叫super,以免丢失QSplashScreen上的图形

默认实现绘制showMessage传递的消息

def drawContents(self, painter):
    painter.drawPixmap(0,0, QPixmap('test2.png'))
    super(SplashScreen, self).drawContents(painter)