QSplashScreen Class

QSplashScreen 위젯은 애플리케이션 시작 시 표시할 수 있는 스플래시 화면을 제공합니다. 더 보기...

헤더: #include <QSplashScreen>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
상속합니다: QWidget

공용 함수

QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags())
QSplashScreen(QScreen *screen, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags())
virtual ~QSplashScreen()
void finish(QWidget *mainWin)
QString message() const
const QPixmap pixmap() const
void repaint()
void setPixmap(const QPixmap &pixmap)

공용 슬롯

void clearMessage()
void showMessage(const QString &message, int alignment = Qt::AlignLeft, const QColor &color = Qt::black)

시그널

void messageChanged(const QString &message)

보호된 함수

virtual void drawContents(QPainter *painter)

재구현된 보호 함수

virtual bool event(QEvent *e) override
virtual void mousePressEvent(QMouseEvent *) override

상세 설명

스플래시 화면은 일반적으로 애플리케이션이 시작될 때 표시되는 위젯입니다. 시작 시간이 긴 애플리케이션(예: 연결을 설정하는 데 시간이 걸리는 데이터베이스 또는 네트워킹 애플리케이션)은 애플리케이션이 로드 중이라는 피드백을 사용자에게 제공하기 위해 스플래시 화면을 자주 사용합니다.

스플래시 화면은 화면 중앙에 나타납니다. 바탕화면의 다른 모든 창 위에 표시하려면 스플래시 위젯의 창 플래그에 Qt::WindowStaysOnTopHint 을 추가하는 것이 유용할 수 있습니다.

일부 X11 창 관리자는 "상단에 유지" 플래그를 지원하지 않습니다. 한 가지 해결책은 스플래시 화면에서 raise()를 주기적으로 호출하는 타이머를 설정하여 "맨 위에 유지" 효과를 시뮬레이션하는 것입니다.

가장 일반적인 사용법은 메인 위젯이 화면에 표시되기 전에 스플래시 화면을 표시하는 것입니다. 다음 코드 스니펫에서는 애플리케이션의 메인 창이 표시되기 전에 스플래시 화면을 표시하고 몇 가지 초기화 작업을 수행하는 예시를 보여 줍니다:

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QPixmap pixmap(":/splash.png");
    QSplashScreen splash(pixmap);
    splash.show();
    app.processEvents();
    ...
    QMainWindow window;
    window.show();
    splash.finish(&window);
    return app.exec();
}

사용자는 마우스로 클릭하여 스플래시 화면을 숨길 수 있습니다. 마우스 처리가 작동하려면 시작 중에 주기적으로 QApplication::processEvents()를 호출하세요.

애플리케이션이 시작될 때 연결이 설정되었음을 알리거나 모듈이 로드되었음을 알리는 등의 메시지로 시작 화면을 업데이트하는 것이 유용할 때가 있습니다:

QPixmap pixmap(":/splash.png");
QSplashScreen *splash = new QSplashScreen(pixmap);
splash->show();

... // Loading some items
splash->showMessage("Loaded modules");

QCoreApplication::processEvents();

... // Establishing connections
splash->showMessage("Established connections");

QCoreApplication::processEvents();

QSplashScreen은 showMessage() 함수를 통해 이를 지원합니다. 직접 그림을 그리려면 pixmap()를 사용하여 스플래시 화면에 사용되는 픽셀맵에 대한 포인터를 가져올 수 있습니다. 또는 QSplashScreen을 서브 클래싱하고 drawContents()를 다시 구현할 수 있습니다.

여러 개의 화면이 있는 경우 기본 화면이 아닌 다른 화면에 스플래시 화면을 표시할 수도 있습니다. 예를 들어

QScreen *screen = QGuiApplication::screens().at(1);
QPixmap pixmap(":/splash.png");
QSplashScreen splash(screen, pixmap);
splash.show();

멤버 함수 문서

[explicit] QSplashScreen::QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags())

pixmap 을 표시할 스플래시 화면을 구성합니다.

위젯 플래그인 f 을 설정할 필요는 없으며, Qt::WindowStaysOnTopHint.

QSplashScreen::QSplashScreen(QScreen *screen, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags())

이 기능은 과부하된 기능입니다.

이 함수를 사용하면 스플래시 화면의 화면을 지정할 수 있습니다. 이 생성자의 일반적인 용도는 화면이 여러 개이고 기본 화면과 다른 화면에 스플래시 화면을 표시하려는 경우입니다. 이 경우 적절한 screen 을 전달하세요.

[virtual noexcept] QSplashScreen::~QSplashScreen()

파괴자.

[slot] void QSplashScreen::clearMessage()

스플래시 화면에 표시되는 메시지를 제거합니다.

showMessage()도 참조하세요 .

[virtual protected] void QSplashScreen::drawContents(QPainter *painter)

페인터를 사용하여 스플래시 화면의 내용을 그립니다 painter. 기본 구현은 showMessage()로 전달된 메시지를 그립니다. 스플래시 화면에 직접 그림을 그리려면 이 함수를 다시 구현하세요.

[override virtual protected] bool QSplashScreen::event(QEvent *e)

다시 구현합니다: QWidget::event(QEvent * 이벤트).

void QSplashScreen::finish(QWidget *mainWin)

위젯 mainWin 이 표시될 때까지 스플래시 화면을 기다렸다가 close()을 호출합니다.

QString QSplashScreen::message() const

현재 스플래시 화면에 표시되는 메시지를 반환합니다.

showMessage() 및 clearMessage()도 참조하세요 .

[signal] void QSplashScreen::messageChanged(const QString &message)

이 신호는 스플래시 화면의 메시지가 변경될 때 발생합니다. message 은 새 메시지이며 메시지가 제거된 경우에는 null 문자열입니다.

showMessage() 및 clearMessage()도 참조하세요 .

[override virtual protected] void QSplashScreen::mousePressEvent(QMouseEvent *)

다시 구현합니다: QWidget::mousePressEvent(QMouseEvent * 이벤트).

const QPixmap QSplashScreen::pixmap() const

스플래시 화면에 사용되는 픽셀맵을 반환합니다. 이미지에는 showMessage() 호출로 그려진 텍스트가 없습니다.

setPixmap()도 참조하세요 .

void QSplashScreen::repaint()

QWidget::repaint()를 재정의합니다. 이벤트 루프가 없는 경우에도 QCoreApplication::processEvents()를 호출하여 업데이트가 표시되도록 한다는 점에서 표준 다시 칠하기 함수와 다릅니다.

void QSplashScreen::setPixmap(const QPixmap &pixmap)

스플래시 화면의 이미지로 사용할 픽셀맵을 pixmap 으로 설정합니다.

pixmap()도 참조하세요 .

[slot] void QSplashScreen::showMessage(const QString &message, int alignment = Qt::AlignLeft, const QColor &color = Qt::black)

message 텍스트를 color 색상으로 스플래시 화면에 그리고 alignment 의 플래그에 따라 텍스트를 정렬합니다. 이 함수는 repaint()를 호출하여 스플래시 화면이 즉시 다시 칠해지도록 합니다. 따라서 애플리케이션이 수행 중인 작업(예: 파일 로드)에 따라 메시지가 최신 상태로 유지됩니다.

Qt::Alignment, clearMessage() 및 message()도 참조하세요 .

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.