[solved] QML app asks for internet connection on maemo device
-
hm... looks like a bug to me too. Fill a "bug report":http://bugreports.qt.nokia.com and post its number here, so we (and other guys in the future) can follow :-)
-
Wait, you're specifically using QNetworkAccessManager or you just mean that XmlListModel uses this?
You have NETWORKACCESS / capability in your PRO file?
And does it work in Simulator if you have turned off your internet? It may be requesting internet but finds it is already enabled in Simulator. -
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- the connection window popping up
- me, canceling the connection dialog
- the application does not display anything
Using the simple ListModel:
- the connection window popping up
- me, canceling the connection dialog
- 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,
Markusdevo.pro:
@QT += core gui declarativeCONFIG += mobility
MOBILITY =TARGET = networkTest
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui
OTHER_FILES +=
main.qml
test.xmlRESOURCES +=
res.qrcmaemo5 {
isEmpty(PREFIX):PREFIX = /usr/local
BINDIR = $$PREFIX/bin
DATADIR = $$PREFIX/shareDEFINES += DATADIR=\\\"$$DATADIR\\\" \ PKGDATADIR=\\\"$$PKGDATADIR\\\" target.path = $$BINDIR INSTALLS += target
}@
main.cpp:
@#include <QtGui/QApplication>
#include "mainwindow.h"int main(int argc, char *argv[])
{
QApplication a(argc, 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;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();protected:
void changeEvent(QEvent *e);private:
Ui::MainWindow *ui;QDeclarativeView *m_view;
};
#endif // MAINWINDOW_H
@mainwindow.cpp:
@#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDeclarativeEngine>
#include <QDebug>MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_view = new QDeclarativeView;
m_view->setSource(QUrl("qrc:main.qml"));
m_view->engine()->addImportPath("qrc:/");
qDebug() << m_view->engine()->importPathList();
setCentralWidget(m_view);
setWindowTitle(tr("Losungen"));
}MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
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.7Rectangle {
id: container
width: 800
height: 480XmlListModel { 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 }
}
@ -
It looks more and more like a bug that will probable take the developer 5 minutes to find and fix but unfortunately will take a VERY long time to make into an official release... You may need to think about a workaround. Any reason not to copy the files to a folder and access them from there?
-
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":http://bugreports.qt.nokia.com/browse/QTCOMPONENTS-275
-
Qt Quick Components is the official name of Qt-Components. The correct category for your bug is "Qt, component Declarative (QML) ":http://bugreports.qt.nokia.com/browse/QTBUG/component/19204
-
[quote author="fcrochik" date="1291747656"] Any reason not to copy the files to a folder and access them from there? [/quote]
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":http://bugreports.qt.nokia.com/browse/QTCOMPONENTS-275 into the correct category ("Qt, component Declarative (QML) ":http://bugreports.qt.nokia.com/browse/QTBUG/component/19204) ?
-
The Trolls are pretty good on checking the bug reports and move them as necessary... More important than the group is the assigned resource and once this one sees something that is not his "expertise/responsibility" he will probably reassign.
At least, that has been my experience...
-
Seems as if the category was already corrected: "Bugreport":http://bugreports.qt.nokia.com/browse/QTBUG-15934
-
The bug report was closed, as the reported behaviour has already been fixed with commit 5120dfec47475dd37f51df4dda9a4ef8494036ab . Unfortunately this commit is not part of the maemo5 20.2010.36-2 package.
See comment of Bea Leam in the "Bugreport":http://bugreports.qt.nokia.com/browse/QTBUG-15934
Regards,
Markus -
Unfortunately that has been the issue with qt on maemo5. Because Qt is part of the "system" it can't be updated by itself.
There has been some discussion on maemo.org if distributing Qt will continue being Nokia responsibility or will be managed by the community. I don't know if the discussion went anywhere (or if it will) but it would be great to have the community manage it so we can have updates more often. If not, it may be worth making a little more flexible the rules about creating applications that depends on the qt-experimental packages.