Tag browsing: Qt

Acceder a Nokia Maps desde QML

May 14th, 2012

Hoy encontré un link a mi blog desde este thread en Nokia Developer en donde preguntaban como abrir la aplicación Nokia Maps (ex Ovi Maps) con unas coordenadas especificas desde una app Qt, hacer esto desde QML es muy fácil, solo debemos usar el método openUrlExternally del objeto Qt de la siguiente manera:

MeeGo
Qt.openUrlExternally("geo:-34.603611,-58.381667")
Symbian
Qt.openUrlExternally("http://m.ovi.me/?c=-34.603611,-58.381667")

Ademas de poder abrir Nokia Maps en una ubicación precisa, con openUrlExternally también es posible, hacer llamados telefónicos, enviar SMSs, emails, abrir una dirección web en el navegador nativo y algunas otras cosas mas, pueden ver algunos ejemplos de esto y su implementación en esta entrada en la wiki de Nokia Developer

Development , , , , No response

Intro a QJson

May 11th, 2012

Hace unos días navegando por los proyectos públicos en Nokia Developer, me tope con un fork de QJson que incluye ciertas modificaciones para poder integrar QJson de forma mas natural con QML, antes ya había escrito como consumir JSON con QML, pero usar esta versión de QJson es mucho mas simple y eficiente.

Para empezar, lo primero que hay que hacer es bajar el proyecto y copiarlo en una carpeta con nombre el QJson en la carpeta raíz de nuestro proyecto.

Luego en el .pro de nuestro proyecto debemos hace un include al .pri de QJson.

include(./QJson/json.pri)

También en el .pro hay que declarar que vamos a usar la función network.

QT += network

En el main.cpp de nuestra app solo hay que crear los includes para QtDeclarative y para QJson y registrar el Type.

#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"

#include <QtDeclarative>
#include "QJson/qjson.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));

    qmlRegisterType<QJson>("QJson", 1, 0, "QJson");

    QmlApplicationViewer viewer;
    viewer.setMainQmlFile(QLatin1String("qml/QColor/main.qml"));
    viewer.showExpanded();

    return app->exec();
}

En la parte QML empezamos agregando un import a QJson, luego crearemos un objeto QJSon y por ultimo vamos a declarar que cuando se dispare el evento Component.onCompleted se le asignara la url a parsear al objeto QJson y luego iteraremos la data resultante de la consulta he iremos asignando lo valores obtenidos a los campos correspondientes del modelo.

import QtQuick 1.1
import QJson 1.0
import com.nokia.symbian 1.1

Page {
    id: mainPage

    ListModel {
        id:colorsModel
    }

    Component {
        id:colorsDelegate
        ListItem {
            height: 100
            Image {
                id:icon
                smooth: true
                width: parent.width
                height: parent.height
                source: imageUrl
                Rectangle {
                    width:parent.width
                    height: 28
                    color:"#000"
                    anchors.bottom: parent.bottom
                    anchors.bottomMargin: 0
                    opacity: 0.750
                    ListItemText {
                        role: "SubTitle"
                        text:title +" by " + userName
                        horizontalAlignment: Text.AlignHCenter
                    }
                }
            }
        }
    }

    ListView {
        anchors.fill: parent
        model: colorsModel
        delegate: colorsDelegate
    }

    QJson {
        id: json
        onError: {
            console.log("line:"+line)
            console.log("message:"+message)
        }
    }

    Component.onCompleted: {
        var data = json.parse("http://www.colourlovers.com/api/palettes/new&format=json")

        for(var p in data){
            colorsModel.append({
                                   "title"   : data[p]["title"]
                                   ,"userName"  : data[p]["userName"]
                                   ,"imageUrl": data[p]["imageUrl"]
                               })
        }
    }
}

Para este ejemplo use el API de ColorLovers para poder consultar las ultimas paletas que se han agregado a su DB, el resultado de este pequeño ejemplo pueden apreciarlo en la siguiente imagen.

QColor Demo

Development , , , , 4 responses

[Actualizado] Meltemi es real

March 21st, 2012

Hasta ahora, lo poco que se sabia sobre Meltemi, eran simples rumores, basados mas que nada en especulaciones, pero hoy gracias a @kypeli que encontró un par de referencias a Meltemi en código de Nokia, se puede afirmar que Meltemi, paso del terreno de las especulaciones, al terreno de la realidad, la primera referencia esta en Pastebin en donde aparece un link a la Wiki de Meltemi en la intranet de Nokia, en una conversación de un empleado de Nokia en lo que parece ser un script usado por el instalador de una versión interna de las herramientas de desarrollo de Meltemi.

http://wikis.in.nokia.com/Meltemi/Developer

Nokia has confirmed the existence of Meltemi. Kinda. http://t.co/BNx2g2gF
@kypeli
Johan Paul

La segunda prueba se encuentra en los repositorios de Qt Sensors, en donde en la cabecera de archivo se puede ver los siguiente:

qirproximitysensor.cpp at The Qt Sensors repository

And Nokia confirmed Meltemi will run Qt. Kinda. http://t.co/1fmWTeWF
@kypeli
Johan Paul

Estas pruebas no hacen mas que confirmar que Meltemi existe, que esta basado en Linux y que Qt es uno de sus pilares, ahora solo resta saber cuando y en que producto se presentara, sera cuestión de seguir esperando, pero viendo el buen trabajo que se hizo con MeeGo/Harmattan, creo que la espera aunque dura, valdrá la pena.

Actualización – 22/03/2012

Las pruebas de la existencia de Meltemi al parecer no duraron mucho en publico, tanto el contenido de Pastebin como el archivo en el repo de Qt Sensors ha sido eliminado, afortunadamente tengo una copia de cada uno de ellos, lo cuales pueden ver a continuación:

Pastebin
From c562d53d77866767beb242df2eee507c7b8bcaf7 Mon Sep 17 00:00:00 2001
From: ------ --------- <------.---------@nokia.com>
Date: Tue, 24 Jan 2012 19:11:39 +0100
Subject: [PATCH] Cleanup package dependencies

---
 mt-make-sysroot |   35 +++--------------------------------
 1 files changed, 3 insertions(+), 32 deletions(-)

diff --git a/mt-make-sysroot b/mt-make-sysroot
index 688bf39..26011d7 100755
--- a/mt-make-sysroot
+++ b/mt-make-sysroot
@@ -166,24 +166,6 @@ function find_executable()
   return 0
 }
 
-function test_object()
-# Usage:
-#
-#   test_object <test> <object> [message]
-#
-# Run <test> (-d/-f/-e/-x/...) for <object>
-# on success return 0
-# on failure print message if supplied and return 1
-{
-  if [ ! "${1}" "${2}" ] ; then
-    if [ -n "${3}" ] ; then
-      echo "${3}"
-    fi
-    return 1
-  fi
-  return 0
-}
-
 function test_package()
 # Usage:
 #
@@ -236,17 +218,8 @@ function check_environment_ubuntu()
   test_package 'mt-dev-env' 'This machine was not setup to run the desktop emulator, yet. Visit http://wikis.in.nokia.com/Meltemi/Developer and do check the prerequisits section' || \
     tool_check=0
 
-  find_executable 'rpm' 'rpm not found. Do "sudo apt-get install rpm"' || \
-    tool_check=0
-
-  #python
-  test_object '-d' '/usr/share/pyshared/M2Crypto' 'python-m2crypto not found. Do "sudo apt-get install python-m2crypto"' || \
-    tool_check=0
-  test_object '-d' '/usr/share/pyshared/urlgrabber' 'python-urlgrabber not found. Do "sudo apt-get install python-urlgrabber"' || \
+  find_executable 'mtz' 'mtz not found. Do "sudo apt-get install mtz"' || \
     tool_check=0
-  test_object '-f' '/usr/lib/build/debtransform' \
-    'python rpm helper module not found. Add the open suse repository to your sources.list and do "sudo apt-get install build"' || \
-      tool_check=0
 
   if [[ $tool_check == 0 ]] ; then
     exit 1
@@ -257,7 +230,7 @@ function check_environment_opensuse()
 {
   local tool_check=1
 
-  find_executable 'rpm' 'rpm not found.' || \
+  find_executable 'mtz' 'mtz not found.' || \
     tool_check=0
 
   if [[ $tool_check == 0 ]] ; then
@@ -269,7 +242,7 @@ function check_environment_redhat()
 {
   local tool_check=1
 
-  find_executable 'rpm' 'rpm not found.' || \
+  find_executable 'mtz' 'mtz not found.' || \
     tool_check=0
 
   if [[ $tool_check == 0 ]] ; then
@@ -595,8 +568,6 @@ init_obs
 function mtz_wrapper()
 {
   arch=$1
-  test_package 'mtz' 'mtz not found, trying to install' || \
-    "${SUDO}" apt-get install mtz || print_error "Installation of mtz failed"
 
   #fix the arch name, since mtz needs to know the real ones used on the reposerver
   arch=`echo $arch | sed -e "s/armv7el/armv7hl/"`
-- 
1.7.4.1
qirproximitysensor.cpp
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtSensors middleware for Meltemi.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include 
#include "qirproximitysensor_p.h"
IMPLEMENT_READING(QIRProximityReading)
/*
    \class QIRProximityReading
    \ingroup sensors_reading
    \inmodule QtSensors
    \brief The QIRProximityReading class holds readings from the IR proximity sensor.
    The IR (infra-red) proximity sensor detects proximity by beaming out infra-red light
    and detecting how much of the light returns.
    The biggest limitation of this technology is that there is no reliable way to turn the
    reflectance values into distances unless both the item being detected and the ambient
    conditions are known.
    \section2 QIRProximityReading Units
    The sensor reports reflectance as a percentage. That is, 0 indicates nothing was detected
    within the range of the sensor and 100 indicates the infra-red signal returned at the full
    power level that it was sent at.
*/
/*
    \property QIRProximityReading::reflectance
    \brief Holds the reflectance value.
    The reflectance is a percentage (from 0 to 100) indicating how much of the transmitted
    infra-red light was returned.
    \sa {QIRProximityReading Units}
*/
qreal QIRProximityReading::reflectance() const
{
    return d->reflectance;
}
/*
    Sets the reflectance value to \a reflectance.
*/
void QIRProximityReading::setReflectance(qreal reflectance)
{
    d->reflectance = reflectance;
}
// =====================================================================

/*
    \class QIRProximityFilter
    \ingroup sensors_filter
    \inmodule QtSensors
    \brief The QIRProximityFilter class is a convenience wrapper around QSensorFilter.
    The only difference is that the filter() method features a pointer to QIRProximityReading
    instead of QSensorReading.
*/

/*
    \fn QIRProximityFilter::filter(QIRProximityReading *reading)
    Called when \a reading changes. Returns false to prevent the reading from propagating.
    \sa QSensorFilter::filter()
*/

char const * const QIRProximitySensor::type("QIRProximitySensor");

/*
    \class QIRProximitySensor
    \ingroup sensors_type
    \inmodule QtSensors
    \brief The QIRProximitySensor class is a convenience wrapper around QSensor.
    The only behavioural difference is that this class sets the type properly.
    This class also features a reading() function that returns a QIRProximityReading instead of a QSensorReading.
    For details about how the sensor works, see \l QIRProximityReading.
    \sa QIRProximityReading
*/

/*
    \fn QIRProximitySensor::QIRProximitySensor(QObject *parent)
    Construct the sensor as a child of \a parent.
*/

/*
    \fn QIRProximitySensor::~QIRProximitySensor()
    Destroy the sensor. Stops the sensor if it has not already been stopped.
*/

/*
    \fn QIRProximitySensor::reading() const
    Returns the reading class for this sensor.
    \sa QSensor::reading()

*/

#include "moc_qirproximitysensor.cpp"
Announcements, Community , , , No response

Symbian Belle, mismo teléfono, nueva experiencia

February 7th, 2012

Hoy 7 de Febrero comenzó el deployment mundial de Symbian Belle, yo vengo usando Belle desde la primera versión que se filtro hace ya unos meses y puedo dar fe de que el cambio es grande y para mejor, pero el motivo de este post no es hablar sobre las mejoras que trae Belle, sino dejarles una lista de recursos que les van a servir a la hora de comenzar a adaptar o crear una nueva aplicación que aproveche el nuevo paradigma que propone Belle.

Diseño

En los siguientes links van a poder encontrar las guiás de diseño para Symbian Belle las cuales les van a permitir conocer los nuevos componentes y patrones que forman parte de la UI y como y donde utilizarlos, también encontraran información sobre la nueva iconografía y templates que les permitirán crear los iconos de sus aplicaciones con la seguridad de seguir al pie de la letra las recomendaciones del equipo de diseño de Nokia.

Desarrollo

La mejor forma de que nuestras aplicaciones se adapten completamente al nuevo estilo y a los nuevos patrones de interacción que trae Belle es usando Qt en conjunto con Qt Components, en la siguiente lista de recursos encontraran, documentación, guiás de publicación, presentaciones y webinars que les permitirán ahondar en este tema.

  • Changes in Symbian Belle and Qt 4.7.4
  • Optimize your apps for Nokia Belle
  • Update your Apps for Nokia Belle
  • Introduction to the Qt Quick Components
  • Qt Quick Components for Designers
  • Qt Quick Components Deep Dive
  • Getting your Qt app running and deployed on Symbian
  • Qt Components for MeeGo and Symbian Phones
  • Announcements, User Interface , , , , 1 response

    Qt DevDays 2011 Videos

    December 19th, 2011

    Ya se encuentran disponibles algunos de los videos de las presentaciones técnicas presentadas durante los Qt DevDays 2011, el numero es reducido aun, pero calculo que con el pasar de los días se irán agregando mas.

    De las presentaciones disponibles, estas son algunas de las mas interesantes según mi criterio, el resto de videos los pueden encontrar aquí.

    Community, Development , No response