Well, it seem then that no, there isn't a built-in way to do waht you want.
 
The shared stuff should go in shared.qrc, and platform-specifics in %platform%.qrc
But then you say: "But as most of the resources are shared between all targets, keeping those resource files in sync is really difficult"
Which doesn't make sense to me, I think you'd be even better off with an explicit file highlighting the differences. I assume as long as you set the prefix correctly, they will be availible in the app. (See code below*)
Otherwise, I'd write a script and generate the QRC at compile time. It's a simple XML format. 
 
//Add custom fonts
QDirIterator it(":/assets/fonts", QDirIterator::Subdirectories);
while (it.hasNext()) {
	QString fontFile = it.next();
	QFontDatabase::addApplicationFont(fontFile);	
	qDebug() << "Added" << fontFile;
}

* I'd test using 2 files and see if they both appear using QDirIterator
 
1.qrc<RCC>
<qresource prefix="/">
<file>assets/fonts/Roboto-Light.ttf</file>
</qresource>
</RCC>
 
2.qrc
<RCC>
​ <qresource prefix="/">
<file>assets/fonts/Roboto-Light.ttf</file>
</qresource>
</RCC>
 
Testing that is left as an exercise to the reader. Let me know how it goes!
 
Sent: Tuesday, January 03, 2017 at 3:59 PM
From: "Bernhard B" <schluc...@gmail.com>
To: interest@qt-project.org, "Jason H" <jh...@gmx.com>
Subject: Fwd: [Interest] Platform dependent *.qrc entries
Hi Jason,
 
thanks for your answer!
 
Maybe I am misunderstanding something here, but isn't that something that happens at runtime? I always thought that all the platform dependent resources are bundled in the resources file and the file selector only selects the right resource for the platform the application is running on.
 
2017-01-03 21:41 GMT+01:00 Jason H <jh...@gmx.com>:
 
+{selector} / 
 
 
Sent: Tuesday, January 03, 2017 at 3:31 PM
From: "Bernhard B" <schluc...@gmail.com>
To: interest@qt-project.org
Subject: [Interest] Platform dependent *.qrc entries
Hi,
 
is it somehow possible to add a resource to the resources file (*.qrc) depending on the targeted platform? I have a few resources that are only needed on specific targets (e.q Android, iOS). Now I would like to make sure that those resources are only added on the targeted platform (to prevent that the executable gets to big). I know, that I can use different *qrc files (depending on the targeted platform) and include them when needed.
 
e.q:

android{
    RESOURCES += android.qrc
}
 
ios{
   RESOURCES += ios.qrc
}
 
But as most of the resources are shared between all targets, keeping those resource files in sync is really difficult. Is there a possibility to use just one *.qrc file and  specify platform dependent entries in a different way?
 
Thanks,
Bernhard
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to