• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QDateEdit

    下一话题

    QDoubleSpinBox

    QSplashScreen

    概要

    函数

    虚函数

    信号

    详细描述

    PySide.QtGui.QSplashScreen widget provides a splash screen that can be shown during application startup.

    闪屏是应用程序启动时,通常显示的 Widget。闪屏常用于长启动时间的应用程序 (如:数据库或花时间建立连接的网络应用程序),为用户提供应用程序加载反馈。

    闪屏出现在屏幕的中心。它可能是有用的,添加 Qt.WindowStaysOnTopHint 到 Splash 小部件的窗口标志,若希望使其保持在桌面所有其它窗口之上。

    Some X11 window managers do not support the “stays on top” flag. A solution is to set up a timer that periodically calls raise() on the splash screen to simulate the “stays on top” effect.

    The most common usage is to show a splash screen before the main widget is displayed on the screen. This is illustrated in the following code snippet in which a splash screen is displayed and some initialization tasks are performed before the application's main window is shown:

    def main():
        app = QApplication(sys.argv)
        pixmap = QPixmap(":/splash.png")
        splash = QSplashScreen(pixmap)
        splash.show()
        app.processEvents()
        ...
        window = QMainWindow()
        window.show()
        splash.finish(&window)
        return app.exec_()
    									

    The user can hide the splash screen by clicking on it with the mouse. Since the splash screen is typically displayed before the event loop has started running, it is necessary to periodically call QApplication.processEvents() to receive the mouse clicks.

    It is sometimes useful to update the splash screen with messages, for example, announcing connections established or modules loaded as the application starts up:

    pixmap = QPixmap(":/splash.png")
    splash = QSplashScreen(pixmap)
    splash.show()
    ... # Loading some items
    splash.showMessage("Loaded modules")
    qApp.processEvents()
    ... # Establishing connections
    splash.showMessage("Established connections")
    qApp.processEvents()
    										

    PySide.QtGui.QSplashScreen supports this with the PySide.QtGui.QSplashScreen.showMessage() function. If you wish to do your own drawing you can get a pointer to the pixmap used in the splash screen with PySide.QtGui.QSplashScreen.pixmap() . Alternatively, you can subclass PySide.QtGui.QSplashScreen and reimplement PySide.QtGui.QSplashScreen.drawContents() .

    class PySide.QtGui. QSplashScreen ( parent [ , pixmap=QPixmap() [ , f=0 ] ] )
    class PySide.QtGui. QSplashScreen ( [ pixmap=QPixmap() [ , f=0 ] ] )
    参数:
    PySide.QtGui.QSplashScreen. clearMessage ( )

    移除在闪屏上显示的消息

    PySide.QtGui.QSplashScreen. drawContents ( painter )
    参数: painter PySide.QtGui.QPainter

    绘制闪屏的内容,使用描绘器 painter 。默认实现绘制传递的消息,通过 PySide.QtGui.QSplashScreen.showMessage() . Reimplement this function if you want to do your own drawing on the splash screen.

    PySide.QtGui.QSplashScreen. finish ( w )
    参数: w PySide.QtGui.QWidget

    使闪屏等待,直到小部件 mainWin is displayed before calling PySide.QtGui.QWidget.close() on itself.

    PySide.QtGui.QSplashScreen. messageChanged ( message )
    参数: message – unicode
    PySide.QtGui.QSplashScreen. pixmap ( )
    返回类型: PySide.QtGui.QPixmap

    Returns the pixmap that is used in the splash screen. The image does not have any of the text drawn by PySide.QtGui.QSplashScreen.showMessage() 调用。

    PySide.QtGui.QSplashScreen. setPixmap ( pixmap )
    参数: pixmap PySide.QtGui.QPixmap

    Sets the pixmap that will be used as the splash screen's image to pixmap .

    PySide.QtGui.QSplashScreen. showMessage ( message [ , alignment=Qt.AlignLeft [ , color=Qt.black ] ] )
    参数:

    Draws the message text onto the splash screen with color color and aligns the text according to the flags in alignment .

    To make sure the splash screen is repainted immediately, you can call PySide.QtCore.QCoreApplication ‘s PySide.QtCore.QCoreApplication.processEvents() after the call to PySide.QtGui.QSplashScreen.showMessage() . You usually want this to make sure that the message is kept up to date with what your application is doing (e.g., loading files).