I have been on the road with the Nokia / Microsoft outreach
program and we have been teaching Windows Phone 7 programming to developers in
Paris, Madrid, Milan, and Berlin. This has been occupying my time and so my
blog has been suffering.
A couple of weeks ago I promised that I would discuss the
process of moving a Qt/QML data driven application to Silverlight. As you may
recall, I did a similar series of blog posts on moving a side scrolling game
from Qt/QML to XNA.
The project of moving a data driven application is somewhat
more complex because you have to worry about mapping pages, page flows, and
page controls from QML into Silverlight. This can be challenging if your
application was developed before the release of Qt Components for Symbian and
you developed your own equivalent of a page stack.
In this series, I will make the assumption that you have a
page stack model for navigating pages my pushing and popping pages on the page
stack. If you have a more hardwired page model, then you will have to make
adjustments to your code to map your method of page navigation into
Silverlight.
Some of the other challenges in moving code from Qt/QML to
Silverlight is the lack of Signals and Slots in C#. There is a comparable
mechanism that allows you to create and connect custom events with custom event
handlers that can be used in place of Signals and Slots. There are some “gotchas” in using events, but we will discuss those
later in this series.
In moving an app from QML to Silverlight I have identified six
steps that can act as a “porting” process. These steps are as follows:
- Identify the QML or Qt Pages.
- Determine the Page states
- Map the Page navigation model
- Enumerate the Page Controls
- Identify signal and slot Connections between
objects
- Map Pages into Silverlight visual Page Specifications (XAML) and C# objects
- Find Silverlight
equivalents for APIs, controls, and connections
It is important to understand that many of the algorithms and much of the code written in JavaScript
and C++ can easily map into Silverlight code behind the Visual Page Specifications.
To
understand this process, you must first understand how Silverlight works. If
you have used Silverlight or Windows Presentation Framework (WPF) in
another context, then these concepts can be directly applied to Windows Phone 7
programming. If you don’t know anything
about Silverlight, then you are in luck because I will spend my next blog
reviewing the structure of a Silverlight application. This will include an
explanation of the organization or Silverlight applications, XAML, and the concept of C# code behind.