pyside6.QtGui.Qmovie无法正常加载gif

问题遇到的现象和发生背景

最近在学习pyside6,想写一个动态加载界面出来,就按照网上的方法用Qmovie来写了,但是写完之后发现无法正常加载GIF

问题相关代码,请勿粘贴截图

class MainWindow(QMainWindow):
def init(self):
super().init()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)

class loginwd(QMainWindow):
def init(self):
super().init()
# 使用ui文件导入定义界面类
self.ui = Ui_loginwds2()
# 初始化界面
self.ui.setupUi(self)
self.ui.ok_pb.clicked.connect(self.login_check)
self.ui.close_pb.clicked.connect(self.close)
# self.ui.buttonBox.Ok.connect(login_check())

def login_check(self):
    user_id = self.ui.name_Edit.text()
    user_pw = self.ui.pw_Edit.text()
    if run_flag:
        # if user_id == 'admin' and user_pw == 'admin':
        self.setDisabled(True)
        Pixmap = QtGui.QPixmap("./loading.gif")
        # Pixmap = QtGui.QPixmap("background.png")
        splash = QSplashScreen(Pixmap)
        splash.setPixmap(Pixmap)
        splashlabel = QtWidgets.QLabel(splash)
        # splashlabel.setGeometry(QtCore.QRect(10, 10, 91, 91))
        splashgif = QtGui.QMovie("./loading.gif")
        splashlabel.setMovie(splashgif)
        splash.show()
        splashgif.start()

        # 定义字体格式
        # font = QtGui.QFont()
        # font.setPointSize(12)
        # font.setBold(True)
        # font.setWeight(QtGui.QFont.Weight(75))
        # splash.setFont(font)
        # splash.showMessage("正在加载。。。", Qt.AlignCenter, Qt.red)
        for i in range(200):
            time.sleep(0.01)
            app.processEvents()
        # splash.showMessage("渲染图片。。。", Qt.AlignCenter, Qt.red)
        # splash.close()
        self.close()
    else:
        QtWidgets.QMessageBox.critical(self, '警告', '错误的用户名或密码')
    pass

if name == "main":
app = QApplication(sys.argv)
loginwd = loginwd()
loginwd.show()
sys.exit(app.exec_())

运行结果及报错内容

现在运行只显示一个灰框,不是gif

img

我的解答思路和尝试过的方法

尝试设置了geomtry,还是无法正常显示

我想要达到的结果

正常显示GIF

少了frameChanged的信号处理,具体参见:

https://blog.csdn.net/this_is_id/article/details/88681276

中的二、动态图片14-16行代码