【问题标题】:Why Graphical effects doesn't change in PyQt5?为什么图形效果在 PyQt5 中没有改变?
【发布时间】:2018-07-15 13:30:13
【问题描述】:

我正在使用 PyQt5 和 Python3 编写程序。 当显示弹出窗口时,我正在使用 QGraphicsBlurEffect 在主小部件上制作模糊效果。 问题是,当弹出窗口关闭时,模糊效果仍在主窗口小部件上,并且不会正常显示。关闭弹窗后如何设置为正常?(我在弹窗关闭事件中将mainwindow的graphicsEffect设置为None,但没有任何改变)。

这是代码:

主小部件:

    self.blureffect = QGraphicsBlurEffect(self) #defining the effect

    def fontpgshow(self): #shows the popup window
        self.setGraphicsEffect(self.blureffect) #puts the blur effect on the main widget

        #the 3 bottom lines show the popup window
        import fontwindow
        self.fontpg = fontwindow.fontpage()
        self.fontpg.show()

弹出窗口:

    def closeEvent(self,event):
        event.accept()
        #in the bottom lines I set the effect of main window to None
        import settingswindow
        self.setpg = settingswindow.settingspage()
        self.setpg.setGraphicsEffect(None)

【问题讨论】:

  • @eyllanesc 有很多代码我不能全部放在这里。你可以看到我的问题是这样的:“在 PyQt 中使用 QGraphicsBlurEffect 的正确方法是什么?
  • 您确定self.setpg 指的是正确的QWidget -- self.setpg.graphicsEffect() 返回什么?否则,显示的代码没有任何明显错误。
  • @G.M.是的,它指的是“设置页面”,这是一个 QWidget,它就像我在软件中的设置页面一样。在设置图形效果之前它返回 None 之后它返回 ` .

标签: python-3.x qt5 pyqt5


【解决方案1】:

我通过将弹出窗口的类型从QWidget 更改为QDialog 解决了我的问题,我在QDialog 中使用了self.accept()self.reject() 将信号发送回此处的主小部件是设置页面。收到信号后,我将主小部件的图形效果设置为None,现在一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-28
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    • 1970-01-01
    • 1970-01-01
    • 2022-12-06
    相关资源
    最近更新 更多