[solved] QML app asks for internet connection on maemo device
Page |
1 |
Hi there,
I wrote a small qml app which uses a XmlListModel filled via an xml in a qrc file. The app runs fine in the QtSimulator. When I deploy the app onto my maemo device (n900) and start it there, the device wants to open a internet connection. The whole app has no reference to the internet. The xml does not even reference a schema… any hints why that happens?
As soon as I connect the device to the internet the applications runs fine.
It seems to that somehow the QNetworkAccessManager makes the device think it needs an internet connection.
I would appreciate any help!
Regards,
Markus
17 replies
hm… looks like a bug to me too. Fill a bug report [bugreports.qt.nokia.com] and post its number here, so we (and other guys in the future) can follow :-)
It’s just the default QNetworkAccessManager that is used by the QDeclarativeEngine to do the transparent NetworkAccess. I do not use a special QNetworkAccessManager.
In the .pro file Qt is configured like that:
- QT += core gui declarative
Concerning the Simulator: What I already tried was switching off the internet connection on OS X. But even without the computer beeing connected to the internet the app worked well in the simulator.
Do you mean turning off the internet in the simulator? I haven’t tried this..thanks for the hint. I will check it tonight.
The cpp part of the app is really just a QMainWindow containing a QDeclarativeView as centralWidget. The rest is implemented in qml.
So I tried to use the qmlviewer to display the qml files. To do that I did not use a qrc file containing the xml, but instead put the xml file into the qml directory. Which lead to:
- XmlListModel {
- id: model
- source: "foo.xml"
- [...]
- }
instead of
- XmlListModel {
- id: model
- source: ":/foo.xml"
- [...]
- }
Using this setup the application works in the qmlViewer and without the n900 asking for an internet connection. =)
I will investigate more tonight.
Hi.
Ok, i prepared a simple example using a ListView with a simple ListModel and another ListView with a XmlListModel.
The behaviour is like that: In both cases the n900 asks for an internet connection. But only when using the simple ListModel, actual data is displayed.
Using the XmlListModel results in
1) the connection window popping up
2) me, canceling the connection dialog
3) the application does not display anything
Using the simple ListModel:
1) the connection window popping up
2) me, canceling the connection dialog
3) the application displays the data
For the interested developer I pasted the sample code.
( I will most likely create a bug report soon, and put the link into this discussion then)
Regards,
Markus
devo.pro:
- QT += core gui declarative
- CONFIG += mobility
- MOBILITY =
- TARGET = networkTest
- TEMPLATE = app
- SOURCES += main.cpp\
- mainwindow.cpp
- HEADERS += mainwindow.h
- FORMS += mainwindow.ui
- OTHER_FILES += \
- main.qml \
- test.xml
- RESOURCES += \
- res.qrc
- maemo5 {
- isEmpty(PREFIX):PREFIX = /usr/local
- BINDIR = $$PREFIX/bin
- DATADIR = $$PREFIX/share
- DEFINES += DATADIR=\\\"$$DATADIR\\\" \
- PKGDATADIR=\\\"$$PKGDATADIR\\\"
- target.path = $$BINDIR
- INSTALLS += target
- }
main.cpp:
- #include <QtGui/QApplication>
- #include "mainwindow.h"
- int main(int argc, char *argv[])
- {
- MainWindow w;
- w.resize(800,480);
- w.show();
- return a.exec();
- }
mainwindow.h
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
- #include <QMainWindow>
- #include <QDeclarativeView>
- namespace Ui {
- class MainWindow;
- }
- {
- Q_OBJECT
- public:
- ~MainWindow();
- protected:
- private:
- Ui::MainWindow *ui;
- QDeclarativeView *m_view;
- };
- #endif // MAINWINDOW_H
mainwindow.cpp:
- #include "mainwindow.h"
- #include "ui_mainwindow.h"
- #include <QDeclarativeEngine>
- #include <QDebug>
- ui(new Ui::MainWindow)
- {
- ui->setupUi(this);
- m_view = new QDeclarativeView;
- m_view->engine()->addImportPath("qrc:/");
- qDebug() << m_view->engine()->importPathList();
- setCentralWidget(m_view);
- setWindowTitle(tr("Losungen"));
- }
- MainWindow::~MainWindow()
- {
- delete ui;
- }
- {
- switch (e->type()) {
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
- }
test.xml:
- <root>
- <item>
- <name>Apple</name>
- <cost>2.45</cost>
- </item>
- <item>
- <name>Orange</name>
- <cost>3.25</cost>
- </item>
- <item>
- <name>Banana</name>
- <cost>1.95</cost>
- </item>
- </root>
main.qml:
- import Qt 4.7
- Rectangle {
- id: container
- width: 800
- height: 480
- XmlListModel {
- id: model
- source: "test.xml"
- query: "//item"
- XmlRole { name: "name"; query: "name/string()" }
- XmlRole { name: "cost"; query: "cost/string()" }
- }
- ListModel {
- id: fruitModel
- ListElement {
- name: "Apple"
- cost: 2.45
- }
- ListElement {
- name: "Orange"
- cost: 3.25
- }
- ListElement {
- name: "Banana"
- cost: 1.95
- }
- }
- // mainView: asks for connection as well,
- // but displays data without connection, too
- // ListView {
- // id: mainView
- // anchors.fill: parent
- // delegate: Text {text: name}
- // model: fruitModel
- // spacing: 5
- // anchors.margins: 5
- // }
- // mainView2 asks for internet connection and does not display any data
- // if there is no connection made
- ListView {
- id: mainView2
- anchors.fill: parent
- delegate: Text {text: name}
- model: model
- spacing: 5
- anchors.margins: 5
- }
- }
I created a bug report.
I think I put it into the wrong category though: Qt Quick Components.
… was the only one with a reference to Qt Quick..
Anyway: here is the Bugreport [bugreports.qt.nokia.com]
Qt Quick Components is the official name of Qt-Components. The correct category for your bug is Qt, component Declarative (QML) [bugreports.qt.nokia.com]
Any reason not to copy the files to a folder and access them from there?
Well, not really. I just like the convenience of the qrc files. You can edit them in the Creator. Then let QtCreator create the .deb package for deployment and that’s it. No hassle with manually putting files into the debian folder of the build directory to get the files into place. =)
I agree… I am just concerned that you won’t have a solution in a short time frame so you probably need a plan B.
The one side effect of having the qml files on a folder is that you can allow people to “enhance” them … of course that also means they can break them :)
What I have done in the past was have the application on startup “extract” the files from the resources to a local folder if they didn’t exist. This way if any problems happen the user can just delete the files from the local folder and the application will recreate them.
If any of the trolls is watching this thread: How can I move my Bugreport [bugreports.qt.nokia.com] into the correct category (Qt, component Declarative (QML) [bugreports.qt.nokia.com]) ?
Seems as if the category was already corrected: Bugreport [bugreports.qt.nokia.com]
You must log in to post a reply. Not a member yet? Register here!






