diff --git a/src/corelib/doc/snippets/resource-system/application.pro b/src/corelib/doc/snippets/resource-system/application.pro index 42c66eba4cf..4b1f1d76353 100644 --- a/src/corelib/doc/snippets/resource-system/application.pro +++ b/src/corelib/doc/snippets/resource-system/application.pro @@ -2,9 +2,9 @@ TEMPLATE = app QT += qml widgets -#! [0] #! [qrc] +#! [0] RESOURCES = application.qrc -#! [0] #! [qrc] +#! [0] #! [1] resources.files = \ diff --git a/src/corelib/doc/snippets/resource-system/mainwindow.cpp b/src/corelib/doc/snippets/resource-system/mainwindow.cpp index de98aa56ec5..35eaa13dbd1 100644 --- a/src/corelib/doc/snippets/resource-system/mainwindow.cpp +++ b/src/corelib/doc/snippets/resource-system/mainwindow.cpp @@ -108,9 +108,9 @@ void MainWindow::createActions() exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, &QAction::triggered, this, &MainWindow::close); -//! [21] +//! [1] cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this); -//! [21] +//! [1] cutAct->setShortcuts(QKeySequence::Cut); cutAct->setStatusTip(tr("Cut the current selection's contents to the " "clipboard")); diff --git a/src/corelib/doc/src/resource-system.qdoc b/src/corelib/doc/src/resource-system.qdoc index 53491bb1c2f..bce25be68d6 100644 --- a/src/corelib/doc/src/resource-system.qdoc +++ b/src/corelib/doc/src/resource-system.qdoc @@ -59,8 +59,8 @@ the \c .qrc file. The path is also used by default to identify the file's content at runtime. - That is, the file \c titlebarLeft.png will be available in the resource system as - \c{:/res/titlebarLeft.png} or \c{qrc:/res/titlebarLeft.png}. + That is, the file \c copy.png will be available in the resource system as + \c{:/images/copy.png} or \c{qrc:/images/copy.png}. To override this default run-time name, see \l{Prefixes} and \l{Aliases}. \e{Qt Creator}, \e{Qt Design Studio}, \QD, and \e{Qt Visual Studio Tools} @@ -102,16 +102,22 @@ variable. If you add a \c .qrc file path to the variable, the listed resource files will be embedded into the generated library or executable: - \snippet resource-system/application.pro qrc + \snippet resource-system/application.pro 0 + + For simple applications, it is also possible to let qmake generate the + \c .qrc file for you, avoiding the need for an additional file to be + maintained: + + \snippet resource-system/application.pro 1 This creates a resource of several \c{.png} files, that are addressable - like this: \c{":/res/titlebarLeft.png"}. + like this: \c{":/images/copy.png"}. If the directory layout of the files you want to embed into the resource doesn't match the expectations of the application, you can specify \c{resources.base}. \c base is a path prefix that denotes the root point of - the file's alias. In the example above, if \c{resources.base} is set to - \c{"res"}, then \c{titlebarLeft.png} is addressable as \c{":/titlebarLeft.png"}. + the file's alias. In the example below, if \c{resources.base} is set to + \c{"images"}, then \c{copy.png} is addressable as \c{":/copy.png"}. \section1 Runtime API @@ -120,7 +126,7 @@ file path to QFile and QDir, but also for instance to the QIcon, QImage, and QPixmap constructors: - \snippet resource-system/mainwindow.cpp 21 + \snippet resource-system/mainwindow.cpp 1 The \c : prefix makes it explicit that "/images/cut.png" should be loaded from the Qt Resource System. @@ -207,6 +213,11 @@ resource file's content and metadata is then done after the compilation and linking phase, through another rcc call. + For qmake, this is enabled by adding \c resources_big to the \c CONFIG + variable: + + \snippet resource-system/application.pro 2 + For CMake, you need to use the \l{qt_add_big_resources} function. \section2 External Resource Files