위젯 튜토리얼 - 창 만들기

위젯이 부모 없이 생성된 경우, 표시될 때 창(또는 최상위 위젯)으로 취급됩니다. 더 이상 필요하지 않을 때 삭제되도록 보장해 줄 부모 객체가 없기 때문에, 애플리케이션 내의 최상위 위젯을 관리하는 것은 개발자의 몫입니다.

다음 예제에서는 ` QWidget `을 사용하여 기본 크기의 창을 생성하고 표시합니다.

#include <QtWidgets>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QWidget window;
    window.resize(320, 240);
    window.show();
    window.setWindowTitle(
        QApplication::translate("toplevel", "Top-level widget"));
    return app.exec();
}
최상위 위젯 애플리케이션 창

실제 GUI를 만들려면 창 안에 위젯을 배치해야 합니다. 이를 위해 QWidget 인스턴스를 위젯의 생성자에 전달해야 하며, 이에 대해서는 이 튜토리얼의 다음 부분에서 설명하겠습니다.

예제 프로젝트 @ code.qt.io

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