views:

64

answers:

1

Is it possible to set HTTP headers for an XmlListModel in QML? Suppose you want to use an XML feed which requires an API key as the data source for a list model. I can pass the API key as an URL attribute, but it would be more elegant to pass it in the HTTP headers. I didn't find anything in the documentation about this. Is it possible to somehow access the QNetworkRequest that is implicitly created?

+3  A: 

You can use your own network access manager by replacing the default factory with a subclassed one;

http://doc.trolltech.org/4.7-snapshot/qdeclarativeengine.html#setNetworkAccessManagerFactory

In your subclassed implementation you would be able to modify the HTTP header by reimplementing the virtual

http://doc.trolltech.org/4.7-snapshot/qnetworkaccessmanager.html#createRequest

Henrik Hartz