Fix resource system documentation
The referred file "titlebarLeft.png" does not exist. In addition, some resource path prefix explainations are wrong Change-Id: I3d88e5baf6a6d1fe45b6174fc18a080d87a0779c Reviewed-by: Jaime Resano <Jaime.RESANO-AISA@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
2dd0c4520f
commit
cc517dd30d
@ -2,9 +2,9 @@ TEMPLATE = app
|
||||
|
||||
QT += qml widgets
|
||||
|
||||
#! [0] #! [qrc]
|
||||
#! [0]
|
||||
RESOURCES = application.qrc
|
||||
#! [0] #! [qrc]
|
||||
#! [0]
|
||||
|
||||
#! [1]
|
||||
resources.files = \
|
||||
|
@ -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"));
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user