このページでは

リソースの管理

Qt プロジェクトに新しいリソースを追加する方法は、通常の C++ プロジェクトにリソースを追加する方法と似ています。主な違いは、Windows の.rc ファイルの代わりに Qt リソースファイル (.qrc ) を使用することです。.rc ファイルとは異なり、.qrc ファイルは Qt がサポートしているすべてのプラットフォームで動作し、Qt コードから読み込むのも簡単です。

新しいリソースを追加するには

  1. Project >Add New Item >Installed >Visual C++ >Qt にアクセスしてください。
  2. Qt Resource File を選択します。

    新規アイテムの追加ダイアログ

  3. Name で、リソース・ファイルの名前を入力します。
  4. Location で、ファイルの場所を指定します。
  5. .qrc ファイルを作成し、Qt Resource Editor で開くには、Add を選択します。

    Qtリソースエディタ

  6. ファイルにリソースを追加するには、Add >Add Files を選択します。
  7. Prefix では、接頭辞を変更できます。

後で Qt コードからリソースを参照するときは、プレフィックス、ファイル名、およびコロンの前に付ける必要があります。例えば、:/MyProject/print.bmp 。

接頭辞の追加

.qrc ファイルに接頭辞を追加するには、Qt Resource Editor でAdd >Add Prefix を選択します。

Qt Resource Editor の起動と Qt Resource Systemも参照してください 。

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