Added example for showing load of qmls from resources

This commit is contained in:
Filippo Cucchetto 2016-03-27 10:40:35 +02:00
parent 4813b30f11
commit efd1a29927
6 changed files with 57 additions and 0 deletions

3
examples/resourcebundling/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
nimcache
main
*.rcc

View File

@ -0,0 +1,16 @@
import nimqml
proc mainProc() =
let app = newQApplication()
defer: app.delete
let engine = newQQmlApplicationEngine()
defer: engine.delete
let appDirPath = app.applicationDirPath & "/" & "main.rcc"
QResource.registerResource(appDirPath)
engine.load(newQUrl("qrc:///main.qml"))
app.exec()
when isMainModule:
mainProc()
GC_fullcollect()

View File

@ -0,0 +1,2 @@
--passL:"-lDOtherSide"
--path:"../../src"

View File

@ -0,0 +1,11 @@
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
ApplicationWindow {
width: 400
height: 300
title: "Hello World"
Component.onCompleted: visible = true
}

View File

@ -0,0 +1,19 @@
# Package
version = "0.1.0"
author = "Filippo Cucchetto"
description = "resourcebundling"
license = "MIT"
bin = @["resourcebundling"]
# Dependencies
requires "nimqml >= 0.5.0"
task compileresources, "Compile the qrc into rcc":
exec ("rcc --binary resources.qrc -o main.rcc")
setCommand("nop")
task compilebinary, "Compile the binary":
setCommand "c"

View File

@ -0,0 +1,6 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource>
<file>main.qml</file>
</qresource>
</RCC>