Development/Tutorials/Necessitas/Assets: Difference between revisions

From KDE TechBase
No edit summary
m (Fix typo (delployment -> deployment))
Line 6: Line 6:
<syntaxhighlight lang="make">
<syntaxhighlight lang="make">
# assuming you want to deploy qml/foo/main.qml file, you need to add the flowing lines to your .pro/.pri file(s)
# assuming you want to deploy qml/foo/main.qml file, you need to add the flowing lines to your .pro/.pri file(s)
delployment.files=qml/foo/main.qml
deployment.files=qml/foo/main.qml
android { #define an android block
android { #define an android block
     delployment.path=/assets/qml/foo #all assets must go to "/assets" folder of your android package
     deployment.path=/assets/qml/foo #all assets must go to "/assets" folder of your android package
} else : maemo5 { #other platforms
} else : maemo5 { #other platforms
     delployment.path=/opt/$${TARGET}  
     deployment.path=/opt/$${TARGET}  
}
}
INSTALLS += delployment
INSTALLS += deployment
</syntaxhighlight>
</syntaxhighlight>



Revision as of 12:19, 6 September 2012

Android assets

Android assets are read-only arbitrary files bundled in their raw form into your package.Necessitas project provides seamless integration with android assets, meaning that you can access any asset files as you access any ordinary files.

Deploy assets

Before accessing an asset we need to deploy it.

# assuming you want to deploy qml/foo/main.qml file, you need to add the flowing lines to your .pro/.pri file(s)
deployment.files=qml/foo/main.qml
android { #define an android block
    deployment.path=/assets/qml/foo #all assets must go to "/assets" folder of your android package
} else : maemo5 { #other platforms
    deployment.path=/opt/$${TARGET} 
}
INSTALLS += deployment

Access assets

QmlApplicationViewer * m_qmlAppViewer;

#ifdef Q_OS_ANDROID
QFile file( "assets:/qml/foo/main.qml" ); // to open a file just use its path and add *assets:/* prefix
m_qmlAppViewer->setSource(QUrl("assets:/qml/foo/main.qml"));
#endif


// do whatever you want with file