이 페이지에서

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 창 관리자는 "stays on top" 플래그를 지원하지 않습니다. 해결책으로는 스플래시 화면에서 주기적으로 ` raise()`를 호출하는 타이머를 설정하여 "stays on top" 효과를 시뮬레이션하는 것입니다.

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

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 *event)를 재구현합니다.

void QSplashScreen::finish(QWidget *mainWin)

스플래시 화면이 위젯 mainWin 이 표시될 때까지 기다린 후, 자체적으로 close()을 호출하도록 합니다.

QString QSplashScreen::message() const

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

showMessage() 및 clearMessage()도 참조하십시오 .

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

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

showMessage() 및 clearMessage()도 참조하십시오 .

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

QWidget::mousePressEvent(QMouseEvent *event)를 재구현합니다.

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()도 참조하십시오 .

© 2026 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.