Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] QML app asks for internet connection on maemo device
Forum Update on Monday, May 27th 2025

[solved] QML app asks for internet connection on maemo device

Scheduled Pinned Locked Moved QML and Qt Quick
18 Posts 5 Posters 10.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    markus.liebe
    wrote on 7 Dec 2010, 10:39 last edited by
    #6

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      markus.liebe
      wrote on 7 Dec 2010, 18:43 last edited by
      #7

      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[])
      {
      QApplication a(argc, argv);
      MainWindow w;
      w.resize(800,480);
      w.show();

      return a.exec&#40;&#41;;
      

      }
      @

      mainwindow.h
      @#ifndef MAINWINDOW_H
      #define MAINWINDOW_H

      #include <QMainWindow>
      #include <QDeclarativeView>

      namespace Ui {
      class MainWindow;
      }

      class MainWindow : public QMainWindow
      {
      Q_OBJECT

      public:
      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.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
      }
      

      }
      @

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fcrochik
        wrote on 7 Dec 2010, 18:47 last edited by
        #8

        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?

        Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

        1 Reply Last reply
        0
        • M Offline
          M Offline
          markus.liebe
          wrote on 7 Dec 2010, 19:02 last edited by
          #9

          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

          1 Reply Last reply
          0
          • A Offline
            A Offline
            anselmolsm
            wrote on 7 Dec 2010, 19:05 last edited by
            #10

            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

            Anselmo L. S. Melo (anselmolsm)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              markus.liebe
              wrote on 7 Dec 2010, 19:07 last edited by
              #11

              [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. =)

              1 Reply Last reply
              0
              • F Offline
                F Offline
                fcrochik
                wrote on 7 Dec 2010, 19:40 last edited by
                #12

                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.

                Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  markus.liebe
                  wrote on 8 Dec 2010, 07:46 last edited by
                  #13

                  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) ?

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on 8 Dec 2010, 11:52 last edited by
                    #14

                    You cannot move it yourself, the "edit issue" is disabled for us users. The only possibility I see is leaving a comment and/or creating a new issue in the right place.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      fcrochik
                      wrote on 8 Dec 2010, 17:21 last edited by
                      #15

                      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...

                      Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        markus.liebe
                        wrote on 9 Dec 2010, 06:58 last edited by
                        #16

                        Seems as if the category was already corrected: "Bugreport":http://bugreports.qt.nokia.com/browse/QTBUG-15934

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          markus.liebe
                          wrote on 13 Dec 2010, 09:27 last edited by
                          #17

                          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

                          1 Reply Last reply
                          0
                          • F Offline
                            F Offline
                            fcrochik
                            wrote on 13 Dec 2010, 14:58 last edited by
                            #18

                            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.

                            Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

                            1 Reply Last reply
                            0

                            15/18

                            8 Dec 2010, 17:21

                            • Login

                            • Login or register to search.
                            15 out of 18
                            • First post
                              15/18
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved