Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Earthquake-Reporting application for Qt and Windows Phone

From Wiki
Jump to: navigation, search
WP Metro Icon Porting.png
SignpostIcon XAML 40.png
WP Metro Icon WP8.png
SignpostIcon WP7 70px.png
Article Metadata
Code ExampleTested with
SDK: Windows Phone SDK 8.0, Qt SDK 1.2
Devices(s): Nokia Lumia 820, Lumia 920
Created: somnathbanik (15 Apr 2012)
Last edited: hamishwillee (25 Nov 2013)



This article demonstrates how to implement the Qt Quick Earthquake-Reporting application with XmlListModel application on Windows Phone 7. The data is obtained from the U.S. Geological Survey and renders the result as a list of earthquake events using a ListBox.

Earthquake Reporting Application



The article Earthquake-Reporting application with XmlListModel explains how the app is implemented in Qt Quick using the XmlListModel QML Element that lets you fetch and parse RSS feeds using only XPath queries


First create an empty Windows Phone project. We add a ListBox to display the data to the left of the screen.

<StackPanel Orientation="Horizontal"  HorizontalAlignment="Left" VerticalAlignment="Top"  Width="350" >                
<ListBox Name ="listboxData" Margin="0,0,-12,0" Loaded="Menu_Loaded"
SelectionChanged="listboxData_SelectionChanged" >
<StackPanel Orientation="Horizontal" Margin="0,0,0,17">
<StackPanel Width="350" Margin="12,-9,0,0">
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}"/>
<TextBlock Text="{Binding PubDate}" TextWrapping="Wrap" Margin="11,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>

We download the data, parse it and bind it to the ListBox.

XElement xmlData = XElement.Parse(e.Result);
XNamespace geo = "";
XNamespace dc = "";
foreach (var item in xmlData.Descendants("item"))
RssData rssData = new RssData();
rssData.Title = (string)item.Element("title").Value;
rssData.PubDate = (string)item.Element("pubDate").Value; = (string)item.Element(geo + "lat").Value;
rssData.lng = (string)item.Element(geo + "long").Value;

When user clicks on any of the list items we display the detail information to the right of the screen.

<Canvas Width="350" Height="313" VerticalAlignment="Top" HorizontalAlignment="Right">
<TextBlock Canvas.Left="10" Canvas.Top="141" Height="30" Name="textBlock1" Text="Lat : " />
<TextBlock Canvas.Left="86" Canvas.Top="141" Height="30" Name="canLat" Text="" TextWrapping="Wrap" />
<TextBlock Canvas.Left="10" Canvas.Top="201" Height="30" Name="textBlock3" Text="Long : " />
<TextBlock Canvas.Left="86" Canvas.Top="201" Height="30" Name="canLng" TextWrapping="Wrap" Text="" />
<TextBlock Canvas.Left="10" Canvas.Top="21" Height="66" Name="canTitle" Text="" Width="323" TextWrapping="Wrap" />
<TextBlock Canvas.Left="10" Canvas.Top="89" Height="40" Name="canSubTitle" Text="" Width="323" TextWrapping="Wrap" />

That's it.

Source Code

This page was last modified on 25 November 2013, at 05:44.
37 page views in the last 30 days.