위젯 튜토리얼 - 창 만들기
부모 없이 위젯을 만들면 표시될 때 창, 즉 최상위 위젯으로 취급됩니다. 더 이상 필요하지 않을 때 삭제되도록 하는 부모 개체가 없으므로 애플리케이션에서 최상위 위젯을 추적하는 것은 개발자의 몫입니다.
다음 예제에서는 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 인스턴스를 전달합니다.
© 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.