ウィジェット・チュートリアル - ウィンドウの作成
ウィジェットが親なしで作成された場合、それが表示されるとウィンドウ、またはトップ・レベル・ウィジェットとして扱われます。ウィジェットは、不要になったときに削除される親オブジェクトを持たないため、アプリケーション内のトップレベル・ウィジェットを追跡するのは開発者次第です。
次の例では、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.