Upload
sean-guerrero
View
232
Download
0
Embed Size (px)
Citation preview
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 1/108
Microsoft & Nokia9/16/2011
Rev1.0
Windows Phone Guide for
Symbian Qt Application
Developer
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 2/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
TableofContent
About this Document ............................................................................................................................ 4 TargetAudience.........................................................................................................................................4 ConventionsUsedinthisDocument..................................................................................................4
Chapter 1: Introducing Windows Phone Platform to Symbian Qt Application
Developers ................................................................................................................................................ 5 WindowsPhoneDeveloperTools........................................................................................................5 WindowsPhoneArchitecture...............................................................................................................6 WindowsPhoneApplicationDevelopmentFrameworks............................................................8 WindowsPhoneApplications.............................................................................................................10 Summary....................................................................................................................................................16 RelatedResources...................................................................................................................................16
Chapter 2: Windows Phone Application Design Guidelines .................................................. 17 DesigningaWindowsPhoneApplication......................................................................................18 WindowsPhoneApplicationStructure............................................................................................19 WindowsPhoneApplicationUserInterfaceDesign....................................................................26 WindowsPhoneApplicationDevelopmentTemplates.............................................................30 Summary....................................................................................................................................................31 RelatedResources...................................................................................................................................31
Chapter 3: Windows Phone Developer and Designer Tools .................................................. 32 ComparingWindowsPhoneandSymbianQtTools...................................................................32 DevelopmentLifeCycleandWindowsPhoneTools..................................................................33 WindowsPhoneUIDesignTools.......................................................................................................35 DevelopingApplicationsinVisualStudio.......................................................................................40 BuildingandDebuggingApplicationsinVisualStudio.............................................................44 WindowsPhoneApplicationDeploymentTools..........................................................................50 WindowsPhoneDocumentationTools...........................................................................................52 Summary....................................................................................................................................................56
Chapter 4: C# programming ............................................................................................................ 57 OverviewoftheC#programming....................................................................................................57 IntroductiontotheC#programminglanguage..........................................................................60 DifferencesbetweenC#andQtC++...............................................................................................71 Summary....................................................................................................................................................74 RelatedResources...................................................................................................................................74
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 3/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter 5: Introducing Windows Phone Application Life Cycle .......................................... 75 ExecutingMultipleApplicationsinWindowsPhone..................................................................75 LifeCycleEventsofaWindowsPhoneApplication....................................................................77 EventHandlersinWindowsPhoneApplications.........................................................................80 Implementingapplicationlife-cyclemanagement.....................................................................81 Summary....................................................................................................................................................85 RelatedResources...................................................................................................................................85
Chapter 6: Porting Applications to Windows Phone ............................................................... 86 RSSReaderExampleApplication.......................................................................................................86 DinerExampleApplication...................................................................................................................89 SudokumasterExampleApplication.................................................................................................93
Match’emPokerExampleApplication.............................................................................................97 Summary....................................................................................................................................................98 RelatedResources...................................................................................................................................98
Chapter 7: Windows Phone Example Applications ................................................................... 99 WindowsPhoneGeneralExamples...................................................................................................99 WindowsPhoneApplicationUIExamples....................................................................................100 WindowsPhoneDeviceIntegrationExamples............................................................................102 WindowsPhoneDataManagementExamples...........................................................................103 WindowsPhoneNetworkingExamples.........................................................................................105
Summary..................................................................................................................................................106 RelatedResources.................................................................................................................................106
Chapter 8: Using the API Mapping Tool .................................................................................... 107 What’stheAPIMappingtool............................................................................................................107 Howtousethetool..............................................................................................................................107 What'snext?............................................................................................................................................108
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 4/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
AboutthisDocument
IfyouhavebeendevelopingQtapplicationsforSymbian^3,SymbianAnna,orSymbian
BelleandareinterestedinbuildingyourapplicationsforWindowsPhone,thisguideis
foryou.
TheguidecoverswhatyouneedtoknowtoaddWindowsPhonedevelopmenttoyour
skillset,whileleveragingwhatyouhavealreadylearnedwhiledevelopingSymbianQt
applications.
TargetAudienceThisdocumentisforSymbianQt4.7applicationdeveloperswillingtodevelop
applicationsforWindowsPhoneOS7.1.
Qt4.7referencedocumentationisavailablein:http://doc.qt.nokia.com/4.7/index.html.
QtQuick1.0componentsdocumentationisavailablein:http://doc.qt.nokia.com/qt-
components-symbian-1.0/qt-components.html .
WindowsPhoneOS7.1developmentplatformdocumentationisavailablein:
http://msdn.microsoft.com/en-us/library/ff637516%28v=VS.92%29.aspx.
ConventionsUsedinthisDocument
Abbreviation Term
WP WindowsPhone
API ApplicationProgrammingInterface
IDE IntegratedDevelopmentEnvironment
XAML ExtensibleApplicationMarkupLanguage
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 5/108
Chapter1:IntroducingWindowsPhone
PlatformtoSymbianQtApplication
DevelopersEversincethereleaseofWindowsPhone(WP)platform,developersfromaroundthe
globerushedtodevelopapplicationsforthisplatform.Now,WPdevicesareavailable
withmanufacturersallovertheworld.Alargenumberofapplicationsarealready
availableintheWPmarketplace.
ForWP,Microsoftwentbacktothedrawingboardtofigureoutwhatphoneusersreally
wantandbuiltaphonefromthegroundup.Theoperatingsystem,theuserexperience
andtheapplicationdevelopmentplatformhaveallbeenengineeredwithusersinmind.
TherevenueopportunitiesintheWindowsPhonemarketplace,accompaniedbyagreatsetofdevelopmenttools,makeWPaveryattractivedestinationfordeveloperstobuild
applicationsandgames.
WindowsPhoneDeveloperToolsAgoodandpractical-orientedapproachtostartwithWPdevelopmentistogetfamiliar
withtheWPapplicationdevelopmenttools.Microsoftrecommendsusingcertaintools
forWPapplicationdevelopment.WPapplicationdevelopmenttoolsetisfreeandcanbe
downloadedfromMSDeveloperAppHub.
Thetoolsetincludes:
AnIDE(fordevelopers):VisualStudioExpressforWindowsPhone
AUIdesigntool(fordesigners):ExpressBlendforWindowsPhone
SilverlightforWindowsPhoneandXNAGameStudioforWindowsPhone
WindowsPhoneemulatortotestanddebugapplications
Thetoolsaredesignedtoletyoudevelopconsumerapplications,businessapplications
andgames.WPtoolsareintroducedinmoredetailinchapter3.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 6/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 6
WindowsPhoneArchitectureBeforegettingintodetailsofWPapplicationdevelopment,it’simportanttogetfamiliar
withtheWPoverallarchitecture.WPutilizesalayeredsoftwareandapplication
architecturethatisdesignedtorunonmultiplephones.Toprovideaconsistentuser
experienceandfeaturesthatyoucanrelyon,WPalsodefinesaminimumsetofhardwarerequirementsthatallWPphonesmustmeet.
WindowsPhoneHardwareFoundation
TheWPhardwarespecificationincludesthefollowinghardwarerequirementsforWP
phones:
ARM7CPU
ADirectXcapableGPU
Camera
Multi-touchcapacitivedisplay Standardsensorsinclude:
o A-GPS
o Accelerometer
o Compass
o Proximityandlightsensors
o Gyroscope
TherearethreestandardbuttonsontheWPphone:Back,StartandSearch.Aswewillsee
insubsequentsections,thesebuttonsprovideaneasyandnaturalnavigationmodelfor
theuser.
InWP,Microsoftprovidesmostofthedevicedrivercode.Adevicemanufacturerhasto
writeverylittledevice-specificcode.Thisimprovestheconsistencyandqualityacross
variousdevices.WPtakesadvantageofhardwareaccelerationthroughencapsulation
layers,suchasDirectXorXNA.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 7/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 7
WindowsPhoneSoftwarePlatform
TheWPsoftwareandapplicationplatformarchitectureismadeupoffourmain
components,asillustratedinthefollowingpicture.
WindowsPhoneapplicationplatformarchitecture
WPRuntimes,i.e.SilverlightandtheXNAFramework,alongwithWindowsPhone–
specificfeatures,combinetoprovideamatureenvironmentonwhichtobuildsecure
andgraphicallyrichapplications.WPTools,namelyVisualStudioandExpressionBlend,
createacompletedeveloperexperienceforquicklycreating,debugging,deployingandupdatingapplications.
WPCloudServices,i.e.WindowsAzure,XboxLIVEServices,Notificationsservicesand
Locationservicesalongwithavarietyofotherwebservices,allowdeveloperstoshare
dataacrossthecloudandprovidesaseamlessexperienceacrossdevices.WPPortal
ServicesandtheWindowsPhoneMarketplaceproviderobustservicesallowing
developerstoregisterandcertifyandmarkettheirapplications.
ManagedCodeinWindowsPhone
Asyoualreadyknow,SymbianQtQuickandC++applicationsarebuiltdirectlyastarget
platformbinaryexecutable.Incontrast,WPonlysupports“managedcode”applications
usingC#orVB.NET;WPapplicationsarebuilttointermediatelanguagebytecodeand
associatedmetadata.
.NETCommonLanguageRuntime(CLR)managestheexecutionofsuchcodewithin
sandboxedenvironment.CLRprovidesgarbagecollectionandthereisnomemory
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 8/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 8
managementtoworryaboutorpointerstotakecareof.TheWPapplicationstackisbuilt
onthe.NETcompactframework.The.NETcompactframeworkisoptimizedforresource
constraineddevicesandisdesignedtobeportableacrossvarioushardwareplatforms.
WindowsPhoneApplicationDevelopment
FrameworksIt’stimetogetabitclosertotheWPapplicationdevelopment.AsaSymbianQt
developeryouhavebecomefamiliarwithusingQtQuick,numerousQtmodulesand
Symbiannativeframeworksinyourapplications.
InWP,applicationsaredevelopedusingvariousWPapplicationdevelopment
frameworks,mostimportantofwhichareSilverlightandXNAframeworksthat
encapsulateseveralimportantandessentialfundamentalfeaturesofapplications.WP
applicationdevelopmentarchitectureisillustratedinthepicturebelow.
WindowsPhoneapplicationdevelopmentarchitecture
InSymbian,thecross-platformQtistherecommendedapplicationdevelopment
framework.However,it’salsopossibletodevelopapplicationsutilizingSymbiannative
frameworks.ThefollowingtablegivesanoverviewoftheWPapplicationdevelopment
frameworksthatprovidefeaturescomparabletotheSymbianQtmodulesandSymbian
nativeframeworks.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 9/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 9
SymbianQt
modules
Symbiannative
frameworks
Functionality WindowsPhone
application
development
frameworks
QtQuick,Qt
Mobility
AVKON,Sensor
Framework,Camera
Framework
ApplicationUI,
Device
integration
(sensors,camera)
Silverlight,Windows
PhoneFrameworks
QtQuick,Qt
Framework
GraphicsandGUI
modules,Qt
Mobility
Graphicspackage,
AnimationsAPI,
MultimediaAPIsandFrameworks
Graphics,
Animation,Media
XNAFrameworksfor
games,Silverlight
Presentationand
Mediaforconsumerandbusiness
applications
QtQuick,Qt
FrameworkEngine
andCoremodules
GenericOSServices,
NetworkingServices,
UserLibrary,XML
Services,Persistent
StorageandFileServer
Baseservices,
Networking,Text,
XML,storage
CommonBaseClass
Library
Symbian OSlayer WindowsPhone
SymbianQt,SymbiannativeandWindowsPhoneapplicationdevelopmentcompared
SeeApplicationplatformoverviewforWindowsPhone formoreinformationaboutWP
applicationdevelopment.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 10/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 10
WindowsPhoneApplicationsAsaSymbianQtdeveloperyouarewellawarethatinSymbianQtthepreferred
applicationdevelopmentframeworkisQtQuickintroducingQML-basedUIs.However,
Symbianapplicationdevelopmentplatformshaveevolvedovertimessocurrentlythere
co-existseveralapplications&gamesutilizingeitherQtwidgets,nativeSymbianframeworksorcustomizedUIs.
InWP,youcandevelopapplicationsusingSilverlightPresentationandMediaandXNA
Frameworks,withthesupportofWindowsPhoneFrameworksandCommonBaseClass
Library.Generally,ithasbeenrecommendedthatWPapplicationdevelopersuse
Silverlightforconsumer&businessapplicationsandXNAforgames.
However,youcancertainlydevelopgreatgamesusingSilverlightanimationor
wonderfulrichmediaconsumerapplicationsusingXNAframework.Inaddition,starting
fromWPOS7.1,itisalsopossibletomixSilverlightandXNAcontentinthesame
application.
ThefollowingtablesummarizescommonarchetypesofWindowsPhoneapplicationsand
theircounterpartsinSymbianQt.
SymbianQtapplications WindowsPhoneapplications
SymbiannativeorSymbianQtQuick
&Qtwidgetapplicationswithstackor
tabbasednavigationbetweenpages
Silverlightconsumerandbusinessapplications
withpagesconnectedbyflows
SymbianQtQuickorcustomizedUI
gameswithOpenGL-ES2Dand3D
graphics
XNAgameswith2D/3DgraphicsandXBOX
connectivity
SymbianandWindowsPhoneapplicationarchetypes
SeeSilverlightandXNAframeworksforWindowsPhoneformoreinformationabout
usingSilverlightandXNAinWPapplicationdevelopment.
Note:AdvertisementscanbepublishedbothinSilverlightandXNAbasedapplications
throughMicrosoftAdvertisingSDK.
SilverlightPresentationandMedia
Fordevelopingrichandevent-driveninternetapplication–styleconsumerandbusiness
applicationsinWP,Silverlightisthepreferredoption.
ComparabletothedeclarativeQMLuserinterfacelanguageusedinQt,Silverlightusesa
declarativelanguagecalledExtensibleApplicationMarkupLanguage(XAML)tospecify
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 11/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 11
userinterfaces.Youcanuseseparatecode-behindfiles,writteninC#orVB.NET,to
respondtoeventsormanipulatethecontrols.
AlargesetofSilverlightUIcontrolsisspecificallydesignedfortheWPOSlookandfeel
andsupportmulti-touch.Silverlightalsoprovideshighperformanceaudioandvideo.It
supportsbothvectorandbitmapgraphicswithhardwareacceleration.
BubbleLevelSilverlightisabasicexampleofaSilverlightapplication.Itdemonstratesthe
usageofaccelerometersensortocalculatetheinclinationofthedeviceandpresentsthis
asatraditionalbubblelevel.BubbleLevelSilverlightisaWPSilverlightportofasimilar
SymbianQtapplicationBubbleLevelQt.
ThefollowingemulatorscreenshotsillustratetheuserinterfaceofBubbleLevelSymbian
QtandWPSilverlightversions.
QtSimulatorscreenshotofBubbleLevelSymbianQtUI
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 12/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 12
WPEmulatorscreenshotofBubbleLevelSilverlightUI
SeeBubbleLevelSilverlightformoreinformationaboutBubbleLevelSilverlightand
portingexperiencesbetweenSymbianQtandWPSilverlight.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 13/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 13
XNAFrameworks
Fordevelopinghighperformancegamesenablingimmersiveandfungamingand
entertainmentexperiencesinWP,XNAframeworkisthepreferredoption.
TheXNAframeworkiscomposedofsoftware,servicesandresourcesfocusedon
enablinggamedeveloperstobesuccessfuldevelopingonMicrosoftgamingplatformslikeWindowsPhone,Xbox360,ZuneHDandWindows7.
TheXNAframework,originallydevelopedforXbox,provideshardwareaccelerated2D
and3Drenderingandbitmapgraphics.XNAalsoprovidesgamerservicessuchas
authenticationandconnectivitywithXboxLive,aswellasProfilesandLeaderboards.
MotoTrialRacerXNAisabasicexampleofaXNAgame.It’samotorcycleracinggame
demonstratingtheusageofXNAGameStudio4.0andespeciallyBox2D.XNA.MotoTrial
RacerXNAisaWPXNAportofasimilarSymbianQtgameMotoTrialRacerQt.
ThefollowingdevicescreenshotsillustratetheuserinterfaceofMotoTrialRacerSymbian
QtandWPXNAversions.
DevicescreenshotofMotoTrialRacerSymbianQtUI
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 14/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 14
DevicescreenshotofMotoTrialRacerWPXNAUI
SeeMotoTrialRacerXNAformoreinformationaboutMotoTrialRacerXNAandporting
experiencesbetweenSymbianQtandWPXNA.
WindowsPhoneFrameworks
WindowsPhoneFrameworksdefinecommonbuildingblocksforWPapplications,such
asapplicationframeandpagestructuresandapplicationactivation/deactivationmechanisms.Inaddition,WindowsPhoneFrameworksprovideWPapplicationsthe
interfacetosystemandhardwareresources.
InQt,WebKitbrowserandwidgetscanbeutilizedfordisplayingHTMLandotherweb
content.IfyouneedtouseHTMLinyourWPapplication,youcanusetheWindows
PhoneFrameworksInternetExplorerbasedwebbrowsercontrolforHTMLUI.
WindowsPhoneFrameworkslayeralsoprovidesinterfacestovarioussensors,suchasthe
accelerometer,compassandgyroscope.Cameraaccessisalsoprovided.Asa
comparison,inSymbianQtaccesstodevicesensorsisavailablethroughQtMobility
SensorsAPI.CameraisaccessiblethroughQtMobilityMultimediaAPI.
Microsoftprovidesapushnotificationservice,calledMicrosoftPushNotificationService,
aspartofWindowsPhoneFrameworks.InSymbianQt,real-timepushnotificationscan
beaddedtoclientapplicationsusingQtNotificationsAPI.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 15/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 15
CommonBaseClassLibrary
InSymbianQt,commonservicesareavailablethroughavarietyofQtFramework
modulesand,tosmallextent,throughQtQuickandQtMobility.InWP,corresponding
baseservicesareprovidedbyCommonBaseClassLibrary.WPCommonBaseClass
Libraryencapsulatesalargesetofcommonfunctionsandcoreservicessuchasbase
classes,collections,threading,textprocessingandIO.
TheWPCommonBaseClassLibrarylayeralsoincludes:
Networkingstacks:suchasHTTPandtheWindowsCommunicationFoundation
(WCF).WCFprovidesaneasyinterfacewithXMLandSOAPservicesacrossthe
Web,withfeaturessupportingtheXMLdatatransfer,serialization,deserialization
andXMLparsing.
Databasesupport:OneofthenewfeaturesinWPOS7.1issupportforlocalSQL
databases.YoucanwriteSQL-likequeriesinC#usingLanguageIntegratedQuery
(LINQ)toqueryXMLdata,storedinisolatedstorageorinremotedatabasessuch
asSQLAzure.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 16/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter1:IntroducingWindowsPhonePlatformtoSymbianQtApplicationDevelopers 16
SummaryInthischapterwelookedattheWPoverallarchitectureandapplicationdevelopment
frameworkscomparedtothecorrespondingSymbianQtandSymbiannative
programmingmodules.NowthatyouhaveanoverallpictureoftheWPplatformanda
high-levelideaofhowtheWPprogrammingframeworksmaptotheSymbianQtandSymbiannativeprogrammingmodules,it’stimetogooneleveldeeper.Inthenext
chapter,wewilllookattheapplicationdesignanduserinterfaceguidelinesofWP
applications.
RelatedResourcesTolearnmoreaboutthetopicscoveredinthisblog,visit:
AppHub–CentralPlaceforWindowsPhonedevelopment.Gettingstarted,
downloadtoolsandreadallaboutWindowsPhonedevelopment
MIX’10presentationonWindowsPhone7ArchitecturebyIstvanCseri
WindowsPhone7DevelopmentforAbsoluteBeginners.Videoseriesthatwill
helpaspiringWindowsPhone7developersgetstarted.
AppHubJumpStartTutorials
IntroductiontoWP7programmingonCodeproject.com
OtherResourcesyoumayfinduseful:
OverviewoftheWindowsPhone7ApplicationPlatform
WindowsPhone7TeamBlog
WindowsPhoneProgramming
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 17/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 17
Chapter2:WindowsPhoneApplication
DesignGuidelines
Microsoft’sWindowsPhone(WP)usesanoveldesignsystemcalledMetro.Whenyou
takeafirstlookatWPstartscreenandWPdesignconcepts,youwillfindsome
differencescomparedtotheSymbianQtdesignyouarefamiliarwith.WPMetro
concentratesoncleanandsimpledesignthatoperatesquickly,surfacesnewinformation
automatically,integratesinteractionsdirectlywithcontentandemphasizesoncolorand
typography.
IncontrasttotheapplicationandmodulefocuseddesignofSymbianQt,WPusesan
information-centricdesign.Insteadofadynamicandcustomizablearrayofapplication
iconsandshortcutsinSymbianQthomescreen,thestartscreenofaWPconsistsof
dynamictilesthatdisplayinformationataglancetotheuser.
Thetilesaredynamicandtheycontinuouslydisplaytheup-to-datestatusofthe
applications.Forexample,theyshowyouthenextappointmentonyourcalendarorthe
numberofnewemailswaitingforyourattention.Userscanpersonalizetheirphonesby
pinningthetilesthattheycaremostabout.
WPalsointroducesanewparadigmcalledhubs.Hubsbringrelatedinformation
together.Therearesixhubs:People,Pictures,Music+Videos,Marketplace,Officeand
Games.ThePeoplehub,inthepictureshownbelow,aggregatesyouraddressbook
contactsandFacebookfriends.
WindowsPhonePeoplehub
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 18/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 18
DesigningaWindowsPhoneApplicationAsaSymbianQtdeveloperyouarewellawarethattherecommendedapplication
developmentframeworkinSymbianisQtQuick.However,theSymbianplatformhas
evolvedovertimesoatthemomentseveralapplicationsandgamesstillutilizeQt
widgets,nativeSymbianframeworks&developmentguidelinesandevencustomizedcomponents&designconcepts.Inthischapter,thecomparisonsbetweenSymbianQt
andWPapplicationdesignaremostlyfromtheQtQuickframeworkperspective.
GeneralApplicationDesignprinciples
EventhoughthenewlyintroducedQtQuickcomponentsbroughtmoremobiledevice
focusedapproachtoSymbianQtdevelopment,thecross-platformnatureofQt
FrameworkaddsanewdimensiontoapplicationdesignonSymbianQtcomparedto
WP.
WhilethedesignoftheWPapplicationisdifferentfromthatoftheSymbianQt,thecoredesignprinciplesareverysimilar.CommontoapplicationdevelopmentinSymbianQt
andothermobileplatforms,inWPyouneedtokeepinmindthecompactscreen,lower
CPU,limitedmemoryandgeneralchallenges&possibilitiesofmobilitywhiledesigning
theapplications.
However,usabilityistheprimarygoalbehindapplicationdesignonbothSymbianQt
andWPplatforms.Theapplicationneedtobesimpleandfocusonkeyscenariosthat
mostuserscareabout.SeeSymbiandesignguidelines andUserexperienceDesign
GuidelinesforWindowsPhone formoreinformationaboutgeneralapplicationdesign
principles.
VisualElementsandDirectManipulation
SimilartoSymbianQt,visualelementsanddirectmanipulationofobjectsbytouchare
thekeycharacteristicsoftheWPapplication.WPprovidesacompletesetofUIcontrols
designedforthephone.InSymbianQt,QtQuickcomponentsareoptimizedforsmall
screenhandhelddeviceswhereasotherQtFrameworkUIcontrolsaredesignedforcross-
platformusage.
WPutilizesalargesetofcoresingletouchandmulti-touchgesturesincludingtap,
doubletap,pan,flick,‘touchandhold’and‘pinchandstretch’.WPtouchgesturesaresemanticallysimilartothegesturessupportedinSymbianQt.Visualandinteraction
designplayakeyroleindevelopingsuccessfulWPapplications.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 19/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 19
WindowsPhoneApplicationStructureWPapplicationstructureisbasedonaSilverlightpagemodelwhereuserscannavigate
forwardthroughdifferentviewsofcontentvialinksandmovebackwardusingthe
hardwareBackbutton.
TherearetwodefinitionsinthecontextoftheSilverlightforWindowsPhonepagemodel:
Page:auser-recognizablecollectionofpersistentstatecontaininginformation,
memorablecontentorlinks
Screen:ageneralUIscreensuchasapop-upwindow,dialogboxorsplashscreen
thatdoesnotcontainmemorablecontentandisnotauser-recognizable
collectionofpersistentstate.
WindowsPhoneApplicationFrameandPage
WPapplicationvisualstructureconsistsofaframeandpagesthatarethecoreelements
ofSilverlightforWindowsPhonepagemodel.Youcancreateasmanydifferentpagesas
neededtopresentthecontentinyourapplicationandthennavigatebetweenthose
pagesusingtheframe.
AframeintegrateswiththeWindowsPhonelookandfeeltoprovideconsistent
appearancebetweenapplications.EachWPapplicationhasasingleframethatcontains:
Apagewhereapplicationcontentisrendered.Thisisthecontentwherewidgets
orgraphicsarerendered.
Areservedspaceforthesystemtray/statusbarandapplicationbar,exposingalsocertainproperties,suchasscreenorientationoftheapplication.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 20/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 20
WindowsPhoneapplicationframeandpage
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 21/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 21
SilverlightforWindowsPhonepagemodelhaslotsofsimilaritieswiththeSymbianQt
Quickapplicationview,thusmakingthetransitiontoWPUIdevelopmenteasier.For
comparison,thebasicapplicationviewofSymbianQtQuickapplication(illustratedinthe
screenshotbelow)consistsofthefollowingareas:
Statusbar(alsoreferredtoassystemtray)displayingsystemstatusiconsand
feedbacksuchassignalstrength,batterylife,Wi-Ficonnectivityandsystemtime. Contentareareservedforapplication-specificcontrolsanddata.Infull-screen
viewcontentareaistheonlymandatoryviewelement.
Toolbarcontainingabackbutton,amenubuttonanduptotwoadditional
buttonsbetweenthem.
ApplicationviewusingQtQuickcomponents
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 22/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 22
ForfurthercomparisonbetweenWPandearlierSymbianapplicationviews,theSymbian
styleapplicationviewsconsistofthefollowingareas:
StatusPanedisplayinginformationaboutthecurrentapplicationandaboutthe
generaldevicestatus(suchassignalandbatterystrength).StatusPanecontains
thetitlepane,contextpane,navipane,signalpane,batterypane,clockpaneand
theuniversalindicatorpanesub-panes. MainPanedisplayingtheapplicationcontentandstate.
ControlPanedisplayingthelabelsassociatedwiththetwosoftkeysproviding
navigationandmenus.
ApplicationviewsfromSymbian^3,SymbianAnnaandSymbianBelle
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 23/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 23
WindowsPhoneApplicationStatusBarandApplicationBar
InWPpagemodel,thereisareservedspaceforthestatusbarandtheapplicationbarin
theapplicationframetopandbottomareas.WPstatusbarandapplicationbar(seethe
picturebelow)havesimilarpurposeandlocationtostatusbarandtoolbarinSymbian
Qt.
TheWPstatusbarincludesindicatorsforavarietyofsystem-levelstatusinformation.The
usermayinteractwiththestatusbar,asitupdatestoprovidedifferentnotificationsand
keeptheuserawareofthingsthatareimportant.
TheWPapplicationbarprovidesaplacetopromoteandlaunchthemostcommon
applicationtasks.Forthelesscommontasks,applicationsmayincludeasinglemenuinto
theapplicationbar.
StatusbarandapplicationbarinWindowsPhoneapplicationarea
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 24/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 24
TypicalStructureofaWindowsPhoneApplication
ThefollowingdiagramshowsthestructureofatypicalWPdata-boundapplication.
TypicalWindowsPhoneapplicationstructure
Whenstartingtheapplication,theuseriswelcomedwithasplashscreenthatiscreating
aperceptionoffastresponseandgivingtheuserimmediatefeedbackthatthe
applicationislaunching.Splashscreensarefixedsizeimagefiles.Forindicatingprogressinapplicationlaunchingsequence,animatedsplashscreensmaybeused.
Usuallytheapplicationstartswiththehomepagethatisthemainnavigationpage
containinglinksforsearch,settingsandotherpagewidgets.Dependingonthe
applicationrequirements,thehomepagecanalsobetheprimarycontentpageatthe
sametime.
Consideranapplicationthatshowsinformationaboutbaseballteamsandtheirplayers.
Theprimarycontentpage,markedasthewidgetspageintheabovediagram,hasthe
contentofinterest,forexamplealistofallbaseballteams.
Thisisapossibleapplicationusagescenario:
Theuserclicksoneoftheteamlinkstovisittheteamdetailspage(“Widget
DetailsPage”)whichcanprovidemultipleviews.Theteamdetailspagemay
employapivotcontrolorpanoramatodisplaydifferentviewssuchastheteam
summaryandthelistofallplayers(“ListofGadgetsPage”)fromthatteam.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 25/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 25
Theuserselectsoneofthebaseballplayers.Accesstoplayerinformationis
restrictedsotheuserneedstogivecredentials(“LoginScreen”)beforethe
applicationtakestheusertothepagewithplayerstatistics(“GadgetDetails
page”).Theplayerstatisticspageusescontrolssuchastextblocks,multi-scale
imagesorothermultimediacontrols.
Theusercanalsousethesearchwidgettosearchanddirectlyaccesstheteampage(“WidgetDetailsPage”)ortheplayerpage(“GadgetDetailsPage”).
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 26/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 26
WindowsPhoneApplicationUserInterfaceDesignWhiletherearesimilaritiesinthedesignprinciplesoftheapplicationsonSymbianQt
andWPplatforms,paycloseattentiontotheuserinterfaceoftheapplicationforWP.Itis
besttotakeadvantageoftheuniquefeaturesandstrengthsofWPplatform.
Fortheuserinterfacetoprovideaconsistentexperienceacrossapplications,WPapplicationsneedtoadoptthenewUserexperiencedesignguidelinesforWindows
Phone.CorrespondingguidancetoSymbianQtQuickapplicationUIdesignisprovided
inSymbiandesignguidelines.SeeSymbian^3UIstyleguidefordesigningnative
Symbian^3applicationUIs.
QMLandXAML
QtQuickutilizesdeclarativeJavaScript-basedQMLuserinterfacelanguagetodescribe
userinterfacesandtheirbehaviorintermsofQMLelementsandQMLdocuments.
SimilarlyWPutilizesdeclarativeXML-basedXAMLuserinterfacelanguageandXAMLdocumentstodescribeapplicationuserinterfaceandelementsinit.
InQt,QMLdocumentisinstantiatedbytheQtC++applicationinvokingtheQML
runtime.SimilarlyinWP,XAMLactsasaninstantiationlanguage.XAMLcontainsthe
actualcodeneededforUIandXAMLdocumentelementshaveadirectmappingtothe
CommonLanguageRuntime(CLR)objects.EventhandlingandXAMLcontrol
manipulationcanbedoneusingseparatecode-behindfileswritteninCLRlanguage(C#
orVB.NET).
ThefollowingcodesnippetsprovideanexampleofsyntaxusedinSymbianQtQMLand
WindowsPhoneXAMLdocuments.
Button {
anchors {
left: sign.right
right: parent.right
verticalCenter: sign.verticalCenter
margins: (parent.width - (sign.x + sign.width)) / 4
}
height: width
source: "images/calibbutton.png"
mouseAreaScale: 2
smooth: true
onClicked: sign.frontSide = !sign.frontSide
}
ExampleofSymbianQtQMLdocumentsyntax
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 27/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 27
<!-- Calibration button, the button style is set to have a nice pressgradient -->
<Button Name="CalibrateButton" Width="158" Height="98"
HorizontalAlignment="Right"
Content="Calibrate" Margin="0,0,30,0" BorderThickness="2"
Foreground="Black"
Click="CalibrateButton_Click" Style="{StaticResource ButtonStyle}">
</Button>
ExampleofWindowsPhoneXAMLdocumentsyntax
Commonfunctionality
WPfeaturesaversatileapplicationbar.Theapplicationbarcanincludeupto4ofthe
mostcommonviewsorapplicationtasks.Youcanalsouseapplicationbarmenusfor
additionalcontext-sensitivetasks.InSymbianQtyoucanusedynamicQtQuickToolbar
toprovidesimilarfunctionalityi.e.menusandcommonlyusedactionsforapplications.Thefollowingtableillustrateshowdevicestatusinformation,navigationfunctionalityand
commonoperationsareprovidedbydifferentviewelementsinSymbianQtQuick,native
SymbianandWPapplications.
SymbianQt
Quick
Symbiannative Functionality WindowsPhone
Statusbar Statuspane Informationabout
device,titles
Statusbar
Pagetitle
Toolbar Controlpaneand
Toolbar
Navigation,Menus,
Buttonsforviewsor
actions
Backbuttonforback
navigation
Tabbar Navipane
Viewandactionson
Applicationbar
SymbianQtQuick,SymbiannativeandWindowsPhoneviewelements
Navigation
OnWP,theusernavigatesforwardbylaunchingapplicationsfromtheInstalled
ApplicationslistorfromaTileonStartscreeninadditiontoothermeans,suchas
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 28/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 28
tappingonatoastnotificationassociatedwithanapplication.WP7.1OSaddstheability
toswitchtoapreviouslyrunningapplicationbypressingandholdingthehardwareBack
button,inasimilarfashiontoSymbianQtapplicationswitchingmechanismthrough
hardwareHome/Menubutton.
TypicalSymbianQtapplicationconsistsofpagesthatcanbenavigatedthroughusing
tabs,GUIcontrols,softkeysandtoolbars.InSymbianQt,hardwarebuttonsarelinkedtosoftkeysthataredisplayedinToolbar(inControlpaneinnativeSymbianstyle
applications).Softkeyscanbeutilizedandconfiguredtosupportcommonnavigation
functions,suchasBack.
TypicalWPapplicationisacollectionofmultiplepageswheretheusernavigatesthrough
differentActivitiesusingwidgetssuchasbuttonsandlinks.OnWP,thehardwareBack
buttonallowstheusertonavigatebackwardsthroughthepagesofarunningapplication
orthroughthestackofpreviouslyrunningapplications.TheBackbuttonalsocloses
menusanddialogs.ThisWPfunctionalityissimilartonavigationusingBackbuttonin
SymbianQtToolbar.
AsaWPdeveloper,youshouldconsiderwhattheBackbuttonmeanstoyouruserand
plantooverrideitappropriately.TheothertwohardwarebuttonsontheWPphone,
namelySearchandHome,havefixedbehavior.
ControlsandtheApplicationInterface
TheWPdevelopmenttoolsandSDKincludearichcollectionofSilverlightcontrolsthat
aredesignedspecificallyforusabilityandaesthetics.Whileyoucancreateyourown
controls,itisbesttousethestandardcontrolswhereverpossible.Thesestandard
controlsrespondtothemechangesandprovideaconsistentuserinterface.
TherearesomesimilaritiesandsomedifferencesbetweenSymbianQtandWPSilverlight
controls.InSymbianQt,therecommendedGUIcontrolsareQtQuickcomponentsand
thesupportingQMLelements.
AnotheroptionforGUIcontrolsinSymbianQtapplications,Qtwidgets,isstillutilizedon
someapplications.However,QtwidgetsarenotrecommendedforQtmobileapplication
developmentanymore.
ThefollowingtableshowsexamplesofcommonSymbianQtQuickcontrols(i.e.QtQuick
componentsandQMLelements)mappedtotheirWPSilverlightcounterparts.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 29/108
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 30/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 30
AnothernotificationmechanisminWPistoastnotificationsthatprovidetimesensitive
information,suchasanSMS.Thetoastnotificationsareshownontopofthescreenfor
about10seconds,buttheusermaychoosetoignorethem.InSymbianQt,similartimer
basednotificationisinfobanner,thatisdisplayedontopoftheactiveapplication.
ThirdnotificationmechanisminWPisrawnotificationsthataredesignedtobeusedin
runningapplicationsandrequireuseraction.SimilarnotificationmechanisminSymbianQtisdialogsthatcontaintextualinformationaboutthenotification,buttonsfor
acceptingauserresponseanddescriptiveiconstoreflectthenatureofthenotification.
WindowsPhoneApplicationDevelopmentTemplatesQtCreatorprovidesafewstandardprojecttemplatesandallowscreationofcustom
projecttemplatesforsettingupbasicQtQuickandQtapplications.VisualStudio
providesnumerousbuilt-intemplatesforWPapplicationdevelopmenttosupport
applicationbasicdesign,thusmakingyourlifeeasier.
YoucanchoosetheWindowsPhoneapplicationtemplatebasedonthefunctionalityof
theapplicationyouaredeveloping.Forexample,theXNA-basedGameapplication
templategivesyourapplicationafoundationtoprovidegame-likefeaturesandmedia
suchasOpenGLESgraphics.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 31/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter2:WindowsPhoneApplicationDesignGuidelines 31
SummaryInthischapterwelookedatthesimilaritiesanddifferenceswhendesigningapplications
forSymbianQtandWPplatforms.WhenyouplanyourWPapplication,youwillbeable
toleverageyourexistingworkandprogramminglogicfromSymbianQtQuick
applications.Inaddition,wecomparedthegeneralstructuresandconceptsinSymbianQtandWP
applicationuserinterfacedevelopmentandintroducedtheWPMetrodesignthatuses
WPinterfaceguidelines.YoualsofoundoutthattheWPSilverlightoffersalargelibrary
ofUIcontrolsandgesturesthathavesomecounterpartsinSymbianQtplatform.
RelatedResourcesTogodeeperintothetopicdiscussed,visit:
WindowsPhoneUserExperienceDesignGuidelines WindowsPhoneDeveloperTools
SilverlightforWindowsPhonetoolkitonCodePlex
DesignresourcesforWindowsPhone
MetroDesignLanguage
OtherResourcesthatyoumayfinduseful:
ApplicationPageModelforWindowsPhone
FrameandPageNavigationOverviewforWindowsPhone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 32/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 32
Chapter3:WindowsPhoneDeveloperand
DesignerTools
WiththereleaseoftheWindowsPhone(WP)developertools,Microsoftbringstheuser-
friendly,highproductivityVisualStudioDevelopmentenvironmenttoWP.AsQt
developeryouarefamiliarwithQtCreatorandQtSDKsoyoucanquicklymigratetoWP
developertoolsandworkwithease.
ComparingWindowsPhoneandSymbianQtToolsInSymbianQtapplicationdevelopment,QtCreatorisacross-platformIntegrated
DevelopmentEnvironment(IDE)tailoredtotheneedsofQtapplicationdevelopers.
EquivalentIDEfornativeSymbianC++applicationdevelopmentisCarbidec++integratingdevice&platformspecificSymbianSDKsandemulators.
InWP,VisualStudio2010ExpressforWindowsPhoneprovidesafull-featuredIDEfor
WPapplicationdevelopment.VisualStudio2010facilitatesdesigning,developingand
debuggingofWindowsPhoneapplications.It’sworthnoticingthatVisualStudioandQt
VisualStudioAdd-incanalsobeusedforQtapplicationdevelopment.
OtheressentialWPtoolsthathelpyouthroughthedevelopmentcycleoftheWindows
Phoneapplicationare:
ExpressionBlend
XNAGameStudio
WindowsPhoneEmulator
SilverlightforWindowsPhoneToolkit
VisualStudioandtheotherabove-mentionedWPapplicationdevelopmenttoolsoffer
similarfunctionalitythatisprovidedbyQtCreatorandtheSymbianQtapplication
developmenttools.Thefollowingtablegivesanoverviewofthefunctionalityofthemost
importantdevelopmenttoolsonbothQtandWPplatforms.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 33/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 33
QtandWindowsPhoneapplicationdevelopmenttools
TheWPtoolsetensuresthattheentireteamofdesigners,developersandtestersfamiliar
withQttoolsetfinditeasytomigratetotheWPdevelopment.
DevelopmentLifeCycleandWindowsPhoneToolsWPtoolsetisdesignedtoaddresstheco-operationandneedsofdifferentmembersin
applicationdevelopmentteam.InasimilarfashiontoQtQuickDesignerandQtCreator
inSymbianQt,ExpressionBlendandVisualStudiofacilitateaclosecollaboration
betweenWPdesignersanddevelopers.
Boththesetoolssharethesamefilestructureandsourcefiles.ExpressionBlenduses
XAMLforUIdesignandtheXAMLisconsumedbyVisualStudio.Thissystemallows
Functionality Audience Qttools WindowsPhonetools
PrimaryUI
design:Colors,
gradientsand
animation
UIdesigners QtQuickDesigner,Qt
Designer
ExpressionBlend
UIdesign UIdesigners
and
programmers
QtQuickDesignerand
QtDesignerintegrated
toQtCreatorIDE
VisualStudio2010
ExpressandExpression
BlendforWindows
Phone
Application
development
(coding)
Programmers QtSDKincludingQt
CreatorIDE
VisualStudio2010
ExpressforWindows
Phone,SilverlightforWindowsPhoneToolkit
Game
development
(coding)
Programmers QtSDKincludingQt
CreatorIDE
XNAGameStudio
Testing/
Emulation
Testers QtSimulatorinQtSDK,
QMLViewer
WindowsPhone
EmulatorinVisual
Studio2010Express
Documentation Development
teamand
stakeholders
Doxygen,QtAssistant NDoc,Sandcastle,
Doxygen,Microsoft
HelpSystem
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 34/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 34
separationofresponsibilitiesbetweenthedesignerandthedeveloperwhileallowing
themtoworktogetherseamlessly,asillustratedbelow.
WPtoolsetsupportsdevelopmentteamco-operation
ManagingprojectsinVisualStudio2010
LikeQtCreator,VisualStudio2010ExpressforWPisafully-featuredIDE.VisualStudio
2010allowsyouto:
Managetheentirestructureofthedevelopmentproject,thesourceandthe
resourcefiles
Configuretheapplicationcodebase,knownasVisualStudioSolution,asacollectionofprojectsinaseparatefunctionalunit
WithVisualStudio2010,youcanmanagesourcefiles,sharecodeandmanagethework
amongteammembers.VisualStudiointegratesacompilerandadebugger.Youcan
accessboththecompilerandthedebuggereitherfromtheGUIorfromthecommand
line.
CreatinganewbasicSilverlightapplicationwithVisualStudioisstraightforward.Westart
WPdevelopmentbycreatingasimpleShoppingList exampleapplicationstepbystep.
1.
StartVisualStudio2010ExpressforWPfromStartmenu.2. InVisualStudio2010,openFilemenuandclickNewProject.
3. IntheNewProjectdialogbox,chooseVisualC#templatesfromtheInstalled
templates.
4. ChooseSilverlightforWindowsPhonetemplatesandselectWindowsPhone
Application.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 35/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 35
5. IntheNametextbox,enternameShoppingList forproject.Selectlocationfor
ShoppingList projectandclickOK .
6. Intheopeningdialog,selectWindowsPhone7.1fromtheTargetWindows
PhoneOSVersiondrop-downlistandclickOK .VisualStudio2010createsthe
newproject.
TheSolutionExplorerpanedisplaysthesolutionthatyoucreated.Thissolutionhasonly
asingleprojectcontainingthesources,resourcesandproperties.
NewWindowsPhoneSilverlightapplicationinVisualStudio
Note:UnlikeQtCreator,VisualStudio2010ExpressforWPdoesnotprovideintegration
withsourcecontrolsystems.TheVisualStudioProfessionaleditionprovidesfeaturessuch
asintegrationwithvarioussourcecontrolsystemslikeSubversion.Youcanalsouse
VisualStudioTeamSystem,whichisdesignedforgreatercommunicationand
collaborationamongthedevelopmentteams.
WindowsPhoneUIDesignToolsTheWPdevelopertoolsforUIdesigninclude:
VisualStudioUIDesigner
ExpressionBlend
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 36/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 36
AsabasistoapplicationUIdesignandUIdesigntools,WPusesaspecificXMLmarkup
language,XAML,fortheUIspecification.InQtQuick,UIspecificationisconstructed
usingJavaScript-basedQMLUIdefinitionlanguage.
VisualStudioUIDesignerforWindowsPhone
VisualStudioUIDesignerforWPhasasimilarpurposeandsetoffeaturescomparedtotheQtQuickDesigner&QtDesignerintegratedtoQtCreatorsoQtapplication
developerswillfinditeasytouse.
BasicapplicationUIdesignwithVisualStudioUIDesignerissimple.Inourexample
project,themainpagefortheShoppingList application,MainPage.xaml ,isalreadyopen
intheVisualStudioUIDesignerforediting.
Tochangethetitlesoftheapplicationandthecurrentpageandtoaddatextblockto
application’scontentarea,dothefollowing:
1.
Right-clicktheapplicationtitleMYAPPLICATIONinVisualStudioUIDesignerandselectProperties.
2. InthePropertieswindow,selectTextandenterSHOPPINGLIST .
3. Similarly,changethetitleofthepagebyenteringMyList intheTextpropertyof
thepagetitle.
4. DragaTextBlock fromtheToolbox.Placeitontopofthecontentpanel.
5. Updatethetextblock’sTextpropertytoItem.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 37/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 37
ApplicationandpagetitlechangedinShoppingList application
TocreatelayoutfortheShoppingList application,dothefollowing:
6. DragaTextBoxfromtheToolboxandplaceitbelowthetextblock.
7. Updatethetextbox’sTextpropertytoemptystring.
8. AbovePropertiestab,clickTextBox1andentertxtItemtochangetheIDofthe
textboxtotxtItem.
9. Resizethetextboxbydraggingitslowerrightcornersothatitswidthis300or
byentering300totextbox’sWidthproperty.
10.DragaButtonfromtheToolboxtotherightofthetextbox.
11.Changethebutton’sContentpropertyto Add anditsIDtobtnAdd .
12.Resizethebuttonsothatitswidthis140.
13.DraganotherTextBoxandplaceitunderneaththetxtItemtextbox.
14.Resizethenewtextboxsothatitcoverstherestofthephonescreen.
15.UpdatetheIDofthenewtextboxtotxtList .
16.UpdatetheTextpropertyofthenewtextboxtoNothinghereyet!.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 38/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 38
CompleteUIlayoutforShoppingList application
17.Tostartdebugging,compiletheapplicationandlaunchitbypressingF5orby
clickingStartDebuggingiconinVisualStudio2010.
VisualStudio2010buildstheShoppingList applicationanddeploysittotheWP
Emulatorthatrunstheapplication.YoucanentertextandclickAddbuttonbutthe
applicationdoesnotrespondbecausethereisnoeventhandlingcodeyetforthe
buttonyouinsertedintheprevioussteps.ThefollowingscreenshotillustratesShoppingList applicationlayoutinWPemulator.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 39/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 39
ShoppingList applicationlayoutinWPemulator
ExpressionBlendforWindowsPhone
ExpressionBlendforWPisavisualUIdesigntoolthatissuitablefordesigners.QtQuick
DesignerandQtDesignerarecloseequivalentstoExpressionBlendinQtdevelopment
toolset.
ExpressionBlendcanbelauncheddirectlyfromVisualStudio’sviewmenu.With
ExpressionBlend,youcan:
DraganddropUIelementstodesigntheUI
Youcanlayoutthecontrolsaccuratelyuptopixels.Youcaneasilycreateanduse
colorpalettesandgradients
Addspecialeffects,suchasreflectionsandshadows
ImportPhotoshopfilesandotherapplicationresourcestotheWindowsPhone
application
Createfineapplicationbehaviorandanimationswithoutanyprogramming
Thefollowingimageshowsthe ShoppingList applicationXAMLUIinExpressionBlend.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 40/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 40
ShoppingList applicationUIinExpressionBlend
ExpressionBlendistargetedforUIdesignersandVisualStudioUIDesignerfor
programmers.ProgrammerscanuseVisualStudioUIDesignertointegratethe
applicationlogictotheUIdesignedwithExpressionBlend.However,VisualStudioUI
DesignercanalsobeusedtodesignUIforapplications.
BothExpressionBlendandVisualStudioUIDesignerhave:
Asinglecontrolsetthatprovidesaccuratefidelitytotheirrun-timevisualrepresentation.Thisfeatureallowsyoutoeasilyvisualizetheapplication.
Sameprojectstructureandsharethesamesourcefilesfordesignersand
developers.
UseorproduceXAML,whichisaSilverlightXMLdeclarativemarkuplanguage
usedforinterfacedesign.Thisfeatureallowsadesignertoworkonthedesign
usingExpressionBlendwhilethedeveloperusesVisualStudiotodesignthelogic
behindtheapplication.Youcanestablishasmoothdesignanddevelopment
workflow.
DevelopingApplicationsinVisualStudioVisualStudiohasasimpletouse,full-featuredandaconfigurablesourceeditor.The
editortoolhasvariousfeaturesthatarefamiliartoQtCreatoreditorusers.Thefeatures
oftheVisualStudioeditorinclude:
Richediting
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 41/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 41
Formatcode
Auto-completionofcode
Outlineorhidecode
VisualStudioeditoriscustomizable.VisualStudioeditorallowsyoutodefinevarious
keyboardshortcutsorcreateyourownmacros.Macroshelpyoutoautomaterepetitive
actionsbycombiningaseriesofcommandsandinstructions.YoucaneasilycustomizeVisualStudioEditortouseshortcutsandkeyboardcombinationsyouarefamiliarwith.
InQtCreator,eachopenedfileusesapartofthemaineditorwindowthatcanbesplit
horizontallyandvertically.ThedefaulteditorviewinVisualStudiousestabbedwindows
forseparatefiles.Youcanchangethisbehaviortosuityourneeds.Youcanchangethe
wayinwhichvariouswindowsaredockedwithinVisualStudioShell.
Let’sreturntoourShoppingList exampleapplication.ToaddlogictotheShoppingList
application,dothefollowing:
18.Tostopdebuggingandtoclosetherunningapplication,pressShift+F5orclickStopDebuggingiconinVisualStudio2010.
19.DoubleclickAddbuttonofMainPage.xamlinVisualStudioUIDesigner.The
VisualStudioeditoropensupanddisplaysMainPage.xaml.cswithamethod
btnAdd_Click.
VisualStudioEditor
20.ToaddlogicfortheitemsthatareaddedtotheShoppingList application,editthe
btnAdd_Click method.Startbyenteringthefollowingcode:
string tStr = txtItem.Text;
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 42/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 42
Note:Whenyouenterletters,VisualStudioeditordisplaysthecontext-sensitiveauto-
completiondialogbox.TheVisualStudioequivalentforQtCreatorcodecompletionis
calledContentAssistant.
Auto-completiondialogboxinVisualStudioeditor
Note:YoucanalsoutilizeVSIntelliSenseandCodeSnippetstoenhanceyourcoding
efficiency.VSIntelliSenseandCodeSnippetsareintroducedshortlyinthefollowing
chapters.
VSIntelliSenseinVisualStudioVSIntelliSenseisaVisualStudiofeatureusinghistory,codecontextand.NETreflection
forintelligentauto-completioninVisualStudioeditor.VSIntelliSensecansuggestand
completevariablenames,parameters,classesandmethodnames.VSIntelliSensecan
alsogenerateappropriatecodewhereneeded,asshowninthecodebelow:
Tocompletetheeventhookup,VisualStudiogeneratesanemptystubfortheeventhandlerbutton1_Clickmethod.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 43/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 43
CodeSnippetsinVisualStudio
CodeSnippetsinVisualStudioareanequivalenttocodesnippetsinQtCreator.Code
SnippetsallowsyoutoinsertcodefragmentswithafewclicksinVisualStudioeditor.
VisualStudiocontainsalargenumberofsnippets.Thesesnippetshelpyoutocreateown
snippets.Youcanalsocreateanindexandsearchforthecodesnippetsbyusingtheself-
definedterms.
ToaddacodesnippettoShoppingList application,dothefollowing:
21.FocuscursortonewlineinthebtnAdd_Click methodofMainPage.xaml.cs.
22.TostarttheInsertSnippetprompt,pressCTRL+KCTRL+XinVisualStudio
editororselectInsertSnippetfromVisualStudioEditmenu.
23.InsertacodesnippetforifstatementtothecodebyselectingVisualC#
followedbyI.InsertSnippetpromptisillustratedbelow:
CodeSnippetinVisualStudioeditor
24.Theinsertedifstatementcodesnippetcanbeusedtowraptheeventhandling
codeinShoppingList application.
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
string tStr = txtItem.Text;
if (true)
{
}
}
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 44/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 44
25.EnterthefollowingcodeinthebtnAdd_clickmethodtocompleteevent
handling:
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
string tStr = txtItem.Text;
if (!String.IsNullOrEmpty(tStr))
{
if (txtList.Text.== "Nothing here yet")
{
txtList.Text = "";
}
txtList.Text += txtItem.Text + Environment.NewLine;
txtItem.Text = "";
}
}
Note:VisualStudiosupportsvariousrefactoringmechanisms.Youcanselectanypieceof
codeandright-clickthecodetoaccesstherefactoringmenu.
BuildingandDebuggingApplicationsinVisualStudioVisualStudio2010ExpressforWPallowsyoutobuildtheVisualStudiosolutionon
demand.Itallowsyoutoseparatelybuildeachprojecttomakeapartofthecomplete
solution.
VisualStudiousesanXMLbased,declarativebuildsystemcalledMSBuild.MSBuildis
equivalenttocross-platformqmakebuildsysteminQtCreator.Youcanaccessthebuilds
eitherfromtheVisualStudioGUIorbyusingthecommandlineforbatchprocessing.
MSBuildisflexibleandallowsyoutocreateaspecifictargeteitherasadebugbuildoras
areleasebuild.
VisualStudiobuildpropertieswindowisshowninthefollowingscreenshot.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 45/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 45
BuildpropertiesinVisualStudio
WindowsPhoneEmulator
TheWPEmulatorprovidesavirtualizedenvironmentinwhichyoucandeploy,debug
andtestapplications.TheWPEmulatorisdesignedtoprovideacomparative
performanceofanactualdeviceandmeetstheperipheralspecificationsrequiredforWP
applicationdevelopment.
ToaccesstheWPEmulatorfromVisualStudio,doanyofthefollowing:
Right-clickprojectfileinSolutionExplorerandclickDeploy
PressF5inthekeyboard,thisstartstheEmulatoralongwiththedebugger
PressCTRL+F5,thisstartsonlytheEmulator
Cross-platformemulatorforQtdevelopment,QtSimulator,enablesapplicationrun-time
emulationofseveralmobiledevicesandmultiplemobileplatformssupportingQt.With
QtSimulatoryoucansimulatevarioussystemeventsandconfigureavarietyofglobal
settings,parametersandpropertiesinplatformenvironmentanddevicehardware.WP
hasspecifichardwarerequirementsandspecifictargetplatformsoinWPEmulator
supportforadjustingdevicehardwareparametersislimited.
DebuggingApplications
VisualStudioExpress2010forWindowsPhoneincludesasymbolicdebuggerthatyou
canusewiththeWPEmulatororwitharemotedevice.Oncetheapplicationloadsinto
thedebugger,youcanviewthevariablesoftheapplicationandcontroltheexecution.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 46/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 46
VisualStudiodebuggerfunctionalitycorrespondscloselytoQtCreatordebuggerplugin
actingasaninterfacebetweentheQtCreatorcoreandexternalnativedebuggerssuch
astheGNUSymbolicDebugger(GDB),theMicrosoftConsoleDebugger(CDB)anda
QML/JavaScriptdebugger.
Toworkwithdebugger,dothefollowingwithShoppingList exampleapplication:
26.Tostartthedebugger,pressF5
27.IntheShoppingList applicationtextbox,enternapkinsandclickAdd.Refertothe
imagebelow.
TestingShoppingList applicationinWPemulator
Note:Todemonstratedebuggingprocess,“napkins” isaddedafter“Nothinghereyet!”
onpurposeinthisversionoftheShoppingList exampleapplication.
28.StopdebuggingbypressingShift+F5.InVisualStudioeditor,clickthegreen
areatotheleftofthefollowingcodeline.
string tStr = txtItem.Text;
AnotheroptionistorightclickthecodelineandselectBreakpoint->Insert
Breakpoint.VisualStudioinsertsabreakpointatthatline.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 47/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 47
BreakpointinVisualStudioEditor
29.LaunchthedebuggeragainusingF5,entertextintotheShoppingList application
textboxandclickAdd.Whentheapplicationstopstothebreakpointinthe
debugger,restthemousepointerovertxtIteminthecode.
30.Click‘+’iconintheopeningpop-uptoviewthedetailsofvariabletxtItem.
TrackingVariables
YoucanviewthedetailsofthevariablessuchastheType,FieldsandProperties.The
dialogscreenshotbelowshowshowyoucanscrollupanddowntheTypeHierarchyto
inspecttheobjects.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 48/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 48
InspectingvariablesinVisualStudio
Youcansetawatchonvariablestokeepthemunderobservationcontinuously.
TotrackvariablesinShoppingList exampleapplication,dothefollowing:
31.Right-clicktxtListandclickAddWatch.TheWatchwindowdisplaysthe
variabletxtList.
32.Click‘+’iconneartxtListtoexpandtxtList.
TrackingvariablesinWatchwindow
33.Toinspectwhythecontroldoesnotenterthefollowingifstatement,pressF10tostepthroughthecode.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 49/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 49
if (txtList.Text == "Nothing here yet")
{
txtList.Text = "";
}
YoucanobserveintheWatchwindowthatthevalueoftxtList.Textis
“Nothinghereyet !” .Itgetscomparedwith“Nothinghereyet ” (withoutexclamationpoint),thisisabuginthecode.Modifythecodetoincludethe
exclamationpointincomparison.
if (txtList.Text == "Nothing here yet!")
Note:Whileinthedebugger,youcanusetheVSimmediatemodewhereyoucanwrite
themanagedcodeinstructionstomodifyorviewthevariablesorexecutecodetohelp
withdebugging.
VisualStudioImmediateWindow
34.Oncethecodeisupdated,re-launchthedebuggerbypressingF5.
35.TotesttheShoppingList application,additemstotheShoppinglist.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 50/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 50
FullyfunctionalShoppingList applicationinWPemulator
ANoteaboutDebugging
YouwillobservethatyoucaneasilydebugaWPapplicationusingthemanaged
programmingenvironment.ThedebugginginWPapplicationisdoneentirelyatthe
applicationlevelusingtheC#codeandtypes.
Note:The.NETframeworkincludestwoclassescalledDebugandTrace,whichhelpyou
towriterun-timedebugmessagestotheoutputwindow.C#alsosupportsanassert
statement,whichisevaluatedatruntime.Ifthestatementreturnstrue,VisualStudio
doesnotrespond.Butifthestatementreturnsfalse,theprogramentersthedebugger.
WindowsPhoneApplicationDeploymentToolsForaWPdeveloper,themostconvenientwaytotestanapplicationduringdevelopment
phaseistouseVisualStudiotodeployittothevirtualizedenvironmentofWindows
Phoneemulator.WindowsPhoneemulatoraddressesmanydevelopmentandusage
scenarios,butintheendit’snaturallyessentialtohavetheabilitytotestandexecuteapplicationinaphysicalWindowsPhonedevice.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 51/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 51
DeployingapplicationstoWindowsPhonedevice
TostartdeployingapplicationsintoWindowsPhonedevice,youneedtoregisteryour
deviceusingWindowsPhone DeveloperRegistrationToolinstalledaspartofWindows
PhoneSDK.Fordeviceregistration,youneedaWindowsLiveIDandavalidAppHub
developeraccountasaprerequisite.Thus,yourdevicemustbeconnectedtoyourhost
computerwhereZuneisinstalledandrunning.
TodeployyourapplicationintoWindowsPhonedevice,youcanuseVisualStudio.For
deployment,youneedaregisteredWindowsPhoneDevicethatmustbeconnectedto
yourhostcomputerwhereZuneisinstalledandrunning.Todeployapplication,just
selecttargetWindowsPhoneDeviceinVisualStudioStandardtoolbar,choose
preferredbuild(DebugorRelease)fromSolutionConfigurationslistboxandpressF5
tostartdeployment.
Note:IfyouareusingVisualStudio2010ExpressforWindowsPhonetodeployyour
applicationtodevice,theSolutionConfigurationslistboxcanbedisplayedinStandard
toolbarbyselectingTools->Settings->ExpertSettings.
AnotheroptiontodeployyourapplicationintoWindowsPhonedeviceistouse
WindowsPhoneApplicationDeploymentToolinstalledaspartofWindowsPhoneSDK.
PrerequisitesareequaltoVisualStudiodevicedeployment.
Note:FordeployingapplicationsthatinteractwithMediaAPI,youshoulduseWindows
PhoneConnectToolfordeviceconnectioninsteadofZune.
SeeDeployingandtestingonyourWindowsPhoneformoreinformationabout
deployingapplicationstodevice.
DistributingapplicationsthroughWindowsPhoneMarketplace
Whenyourapplicationimplementationiscompleted,youcansubmityourapplicationto
theWindowsPhoneMarketplace todistributeittootherWindowsPhoneusers.
WindowsPhoneMarketplaceTestKittool(installedaspartofWindowsPhoneSDK)can
beusedtomakesureyourapplicationmeetstheWindowsPhoneMarketplace
publishingrequirements.
OnceyourapplicationmeetstheprerequisitesforWindowsPhoneMarketplace,youcan
submityourapplicationtoAppHubforWindowsPhoneApplicationcertification.After
thatyourcertifiedapplicationcanbepublished,distributedandmaintainedthrough
WindowsPhoneMarketplace.
In a nutshell, the Windows Phone application distribution lifecycle consists of thefollowing general steps:
1. Register as a Windows Phone Developer in App Hub2. Develop and test your application
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 52/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 52
3. Assemble the prerequisites for Windows Phone Application Certification4. Submit your application to App Hub for certification5. Publish your application into the Windows Phone Marketplace6. Add links to your application in the Windows Phone Marketplace Catalog7. Update your application in the Windows Phone Marketplace
SeeDevelopingandpublishingapplicationsoverviewforWindowsPhoneMarketplaceformoreinformationabouthowtopublishyourapplicationstotheWindowsPhone
Marketplace.
WindowsPhoneDocumentationToolsQTCreatorhasanintegratedbrowser-likehelptoolcalledQtAssistantthatcanalsobe
utilizedasanapplication-specificdocumentationtool.However,inmostoftheSymbian
QtapplicationsAPIdocumentationisconstructedutilizingexternaldocumentationtools,
suchasDoxygen,thatcanbeusedstand-aloneorintegratedtoQtCreatorasaplugin.
WPdevelopersbenefitfromMicrosoft’sfeature-richHelpSystemthatisintegratedto
VisualStudioandutilizesbothlocallyinstalledandMSDNOnlinecontent.For
constructingAPIdocumentation,youcanuseexternaldocumentationtoolsorinclude
XMLtagsinspecialcommentfieldsinWPapplicationsourcecodeandVisualStudio
compilercreatesaXMLdocumentationfileforyou.
Note:VisualStudioeditorhasafeaturethatmakesiteasytocreatebasiccode
commentsforXMLdocumentationfile.Placethecursorjustaboveaclassoramember
andtypethe‘ / ’characterthreetimes.VisualStudiocreatesaskeletonforcodecomment
block.Whenyoupressthe‘<'keyfornewtagincodecommentblock,VSIntelliSense
selectorshowsalistofavailablecodecommenttags.
ToaddcommentsandtocreateXMLdocumentationfilefortheShoppingList example
application,dothefollowing:
36.StopdebuggingbypressingShift+F5.InVisualStudioSolutionexplorer,
double-clickMainPage.xaml.cstoopenitupinVisualStudioeditor.
37.FocuscursortothelinebeforebtnAdd_Click methodofMainPage.xaml.csand
typethe‘ / ’characterthreetimes.VisualStudiocreatesthefollowingskeletonfor
methodcommentblock:
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 53/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 53
Skeletonfor btnAdd_Clickmethodcommentblock
38.Addmethodsummarycommentinside<summary>tagsasillustratedbelow.
Clickthe‘<'keyandselect<code> tagstomarktxtItemandtxtListas
codeinside<summary> tags.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 54/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 54
Adding <code> tagsforcodeobjectsinside <summary> tags
39.Completethemethodcommentsbydescribingparametersinside<param>tags
andaddfurthercommentstoShoppingList applicationclassesandmethods.
40.Whenready,right-clickShoppingList applicationprojectfileinVisualStudio
SolutionexplorerandchooseProperties.
41.IntheleftpaneoftheShoppingListpropertieswindow,clickBuild.42.ChecktheXMLdocumentationfilecheckboxandchooseanameandlocation
fortheXMLdocumentationfiletobecreated.
43.BuildyourprojectbypressingF6andVisualStudiocompilercreatestheXML
documentationfile.LocateandviewthegenerateddocumentationfileinXML
format.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 55/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 55
XMLdocumentationfileforShoppingList application
Tocreatefinaldocumentationdirectlyfromcodecommentsorfromthecompiler-
generatedXMLdocumentationfile,thereisavarietyoffreedocumentgenerationtools
availablefor.NET,suchas: NDoc
Sandcastle
Doxygen
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 56/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter3:WindowsPhoneDeveloperandDesignerTools 56
SummaryInthischapterwelookedattheWindowsPhonetoolsetforapplicationdevelopment.
WPtoolsethassimilaritieswiththeQtdevelopmenttoolssoQtdevelopersfindtheWP
toolseteasytomigrateto.Thefeature-richtoolsinWPtoolsetaredesignedtosupport
everystepintheentireapplicationdevelopmentlifecycle.Thedesign,developmentandtestingtoolsseamlesslysupporttheco-operationofthewholeapplicationdevelopment
team.ThetightintegrationbetweentheWPtoolshelpsyoutostreamlinethedesignand
develop&testtheworkflow.WPtoolsprovideanend-to-endfunctionalityandare
highlycustomizable.
RelatedResources
TogetmoreinformationaboutWindowsPhonedevelopertools,visit:
ExpressionBlend
XNAGameStudio
WindowsPhoneEmulator
SilverlightforWindowsPhoneToolkit
OtherResourcesyoumayfinduseful:
Exercise:CreatingWindowsPhoneApplicationswithMicrosoftVisualStudio
Howto:BuildandDeployaWindowsPhoneApplicationUsingVisualStudio
DebuggingWindowsPhoneApplications
DeployingandTestingonYourWindowsPhone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 57/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 57
Chapter4:C#programming
MicrosoftWindowsPhone(WP)applicationsaredevelopedusingVB.NETorC#
programminglanguagesandcorrespondinglibraries.Inthepreviouschapterwealready
tookafirstlookattheC#programminglanguagewhiledevelopingtheShoppingList
exampleapplicationandgettingfamiliarwiththeWPapplicationdevelopmenttools.
ThischaptermapstheessentialWPC#languagefeaturestothesimilarC++language
featuresinQt.OverviewoftheC#programminglanguageisprovidedandthemost
importantWPC#featuresaredescribedtohelpyouwritesafeandqualitycode.
CommonidiomsandprogrammingconceptsinWPC#arecomparedtoQtC++and,in
addition,examplecodesnippetsareprovidedtohelpyougetfamiliarwithWPC#code
fasterandenhanceproductivity.
OverviewoftheC#programmingC#isanelegantandtype-safeobject-orientedprogramminglanguagethatenables
developerstobuildavarietyofsecureandrobustapplicationsthatrunonthe.NET
Framework.C#syntaxishighlyexpressive,yetitisalsosimpleandeasytolearnto
anyonefamiliarwithC,C++orJava.
C#syntaxsimplifiesmanyofthecomplexitiesofC++andprovidespowerfulfeatures
suchasnullablevaluetypes,enumerations,delegates,lambdaexpressionsanddirect
memoryaccess,whicharenotfoundinJava.C#supportsgenericmethodsandtypes,
whichprovideincreasedtypesafetyandperformance,anditerators,whichenableimplementersofcollectionclassestodefinecustomiterationbehaviorsthataresimpleto
usebyclientcode.Language-IntegratedQuery(LINQ)expressionsmakethestrongly-
typedqueryafirst-classlanguageconstruct
Asanobject-orientedlanguage,C#supportstheconceptsofencapsulation,inheritance
andpolymorphism.Allvariablesandmethods,includingtheMainmethod,the
application'sentrypoint,areencapsulatedwithinclassdefinitions.Aclassmayinherit
directlyfromoneparentclass,butitmayimplementanynumberofinterfaces.Methods
thatoverridevirtualmethodsinaparentclassrequiretheoverridekeywordasawayto
avoidaccidentalredefinition.InC#,astructislikealightweightclass;itisastack-allocatedtypethatcanimplementinterfacesbutdoesnotsupportinheritance.
ThefollowingchaptersgiveanoverviewofWindowsPhoneC#applicationsin.NET
frameworkandtheC#programmingguidelinesandconventions.SeeIntroductiontothe
C#languageforwideroverviewoftheC#programminglanguage.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 58/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 58
ManagedProgrammingin.NETframework
InSymbianQt,theC++codeiscompiledandbuiltdirectlytoexecutableforSymbianQt
targetplatform.WPsupportsmanagedprogramminginC#(andVB.NET),asvisualizedin
thefollowingimage:
Managedprogrammingvisualized
InWP,theC#compiler(andsimilarly,theVBcompiler)compilestheC#(orVB.NET)code
toanintermediatelanguage(IL)bytecodethatconformstotheCommonLanguage
Infrastructure(CLI)specification,andtoassociatedmetadata.TheCommonLanguage
Runtime(CLR)executesthebytecode.TheC#usesmetadatatomanagetypesafety,
exceptionhandlingandarraybounds.CLRalsomanagesmemoryandperformsgarbage
collection.
OverviewofaWindowsPhoneC#applicationWPC#applicationscanconsistofoneormore.csfiles.Eachfilecancontainzeroor
morenamespaces.Anamespacecancontaintypessuchasclasses,structs,interfaces,
enumerationsanddelegates,inadditiontoothernamespaces.Thefollowingcode
snippetoutlinesaskeletonforaWPC#applicationcontainingthesebasicelements.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 59/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 59
// A skeleton of a C# application
using System;
namespace YourNamespace
{
class YourClass
{
}
struct YourStruct
{
}
interface IYourInterface
{
}
delegate int YourDelegate();
enum YourEnum
{
}
namespace YourNestedNamespace
{
struct YourStruct
{
}
}
class YourMainClass
{
static void Main(string[] args)
{
// Your program starts here...
}
}
}
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 60/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 60
TheC#LanguageSpecificationdoesnotdefineanexplicitcodingstandardforC#
applications.C#codingconventionsdescribesgeneralconventionsandbestpracticesfor
layoutandcodecommentingandprovidesguidelinesforC#languageusage.Common
namingconventionsforC#applicationsarecoveredinGuidelinesforNames.Secure
codingguidelinesanddesignguidelinesforclasslibrariesprovideaunified
programmingmodelthatpromotesquality,securecodeandconsistencyinC#applicationdesign.
IntroductiontotheC#programminglanguageInthischapter,thefollowingessentialidiomsandconceptsofWPC#programming
languageareintroducedandcomparedtotheSymbianQtC++programminglanguage:
ManagedProgramming
Threading
Timers
DataBinding
MemoryManagement
BaseClass
ClassReference
ClassDeclaration
Polymorphism:Baseclass
Polymorphism:Derivedclass
Interfaces:Interface
Interfaces:Implementation
Properties:Definingaproperty Properties:Auto-implementedproperties
Struct
ExceptionHandling
EventHandling
Thefollowingtableaddressestheabove-mentionedessentialprogramminglanguage
idiomsandprovidesaquickcomparisonbetweenWPC#andSymbianQtC++
programminglanguages.Seetheattachedlinksformoreinformationaboutthetopics.
InadditiontoWPC#andSymbianQtC++languages,implementationofsomefeatures
includesusageofUIdescriptionlanguagesXAMLandQMLrespectively.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 61/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 61
Comparison WindowsPhoneC# SymbianQtC++
Managed
Programming
WPC#codeiscompiledtointermediate
languagebytecodeandmetadata.Byte
codeisexecutedbyTheCommon
LanguageRuntime(CLR)thathandlesmemorymanagementandperforms
destructionofobjectsthroughgarbage
collection.
QtC++codeiscompileddirectlytotarget
platformexecutable,thereisno
intermediatelanguageinbetween.Qt
C++developerisresponsibleformemorymanagement.
Threading
WPC#applicationshavetwothreads,the
UIthreadandthecompositionthread.
TheUIthreadisthemainthreadin
Silverlightapplicationtakingcareofthe
XAMLhandling,first-timedrawingof
visualobjects,pre-framecallbacksand
executingotherusercode.
Thecompositionthreadhandlessome
workthattheUIthreadwouldnormally
handle.Thecompositionthreadcombines
graphicstexturesandpassesthemtothe
GPUfordrawing.Simplestoryboard-
drivenanimationsarealsopassedtoGPU
processingbycompositionthread.
ToavoidblockingthemainUIthread,
applicationdeveloperscanutilize
secondarybackgroundthreadsor
BackgroundWorkerclasstoperform
time-consumingtaskssuchasdownloads
anddatabasetransactions.
Movingdatafrombackgroundthreadto
theUIthreadcanbeimplementedusing
sharedvariablesandanevent,orby
sendinganotificationtotheUIthread
usingDispatcher.BeginInvoke
method.BackgroundWorkerclasshas
ownevent-basedmechanismfor
backgroundprocessing.Readmorefrom:
http://msdn.microsoft.com/en-
us/library/ff967560(v=vs.92).aspx#BKMK_T
hreads
SymbianQtC++applicationshaveone
mainthreadinwhichmaineventloopis
runningandUIcontrolscanbeaccessed.
UIoperationsareonlyallowedfromthe
applicationmainthread.
Whenasynchronousoperationsarelikely
totakealongtimeandlotofplatformresources,usageofQt’splatform-
independentQThreadthreadsseparately
maybeagoodimplementationsolution.
Tocreateathread,subclassQThreadand
re-implementtherun()function.
class MyThread : publicQThread
{
Q_OBJECT
protected:
void run();
};
void MyThread::run()
{
...
}
EventhandlingbetweenSymbianQt
applicationthreadscanbeimplemented
usingasynchronousnotificationsthrough
signalsandslotsmechanism.
Notethatsimilarthreadingsystemisalso
availablethroughQMLWorkerScript
Element.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 62/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 62
Timers
TimerclassinWPC#providesasimple
timerthatexecutescallbackmethodsat
specifiedintervals.Timer runsina
differentthreadthantheapplicationmain
UIthreadand,inordertoaccessobjects
oftheUIthread,itisnecessarytoinform
theDispatcherTimeroftheUIthreadusingDispatcher.BeginInvoke .
Toimplementtimerdirectlyintothe
applicationmainUIthread,
DispatcherTimerclasscanbeused.
DispatcherTimertimerisintegrated
intotheDispatcherqueuewhichis
processedataspecifiedintervaloftime
andataspecifiedpriority.
ReadmoreaboutTimerfrom:
http://msdn.microsoft.com/en-
us/library/system.threading.timer(v=vs.95).
aspx
ReadmoreaboutDispatchedTimer
from:http://msdn.microsoft.com/en-
us/library/system.windows.threading.dispa
tchertimer(v=vs.95).aspx
QObject,thebaseclassofallQtobjects,
providesthebasictimersupportin
SymbianQt.Whenyourapplicationis
runningineventloop,youcanstarta
timerwithQObject::startTimer().
ThemainAPIfortimerfunctionalityis
QTimer .QTimer classprovidesregular
timersthatemitasignalwhenthetimer
fires.
QTimer *timer = newQTimer(this);
connect(timer,SIGNAL(timeout()), this,SLOT(doSomething()));
timer->start(1000);
Thistimermechanismcanalsobeusedin
multithreadedapplicationsi.e.inany
threadthathasaneventloop.
Notethatsimilartimermechanismisalso
availablethroughQMLTimerelement.
Readmorefrom:
http://doc.qt.nokia.com/stable/timers.html
DataBinding
DatabindinginWPC#providesasimple
waytodisplayandinteractwithdata,
allowingdatatoflowbetweentheUIand
adataobject.
Whenabindingisestablishedandthe
datachanges,theUIelementsthatare
boundtothedatacanreflectchanges
automatically.Similarly,changesmadeby
theuserinaUIelementcanbereflected
inthedataobject.
DatabindinginWPC#applicationscan
beimplementedthroughXAMLor
programmaticallywithC#code.
InXAML,thebindingiscreatedusing
Bindingobjectelement.Bindingcan
alsobeexpressedasanXAMLattribute.
Propertybindingisapowerfulfeatureof
SymbianQtthatallowsvaluesofdifferent
elementstobespecifiedinadeclarative
wayandsynchronizedautomatically.It
usessignalstonotifyandupdateother
elements'valueswhenpropertyvaluesare
changed.
PropertybindingsarecreatedinQML
usingthecolon":"beforethevalue,for
example:
Rectangle {
width: parent.width
}
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 63/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 63
InC#code,bindingcanbecreatedusing
Bindingclass:
//Create the source string
string s = "Hello";
//Create the bindingdescription
Binding b = new Binding("");
b.Mode = BindingMode.OneTime;
b.Source = s;
//Attach the binding to thetarget
MyTextBox.SetBinding(TextBlock.TextProperty, b);
Readmorefrom:
http://msdn.microsoft.com/en-
us/library/system.windows.data.binding(v
=vs.95).aspx
Sometimesitisnecessarytobindexplicitly
toapropertyofanobjectthatwasn't
directlyinstantiatedbyQML-generallya
propertyofaclassexportedtoQMLby
C++.
TheQMLelementBindingprovidesa
mechanismtocreatebindingsbetween
propertiesexposedfromC++andvalues
comingfromQML.Forexample:
Binding {
target: system
property: "brightness"
value: slider.value
}
Readmorefrom:
http://doc.qt.nokia.com/latest/propertybin
ding.html
Memory
Management
WPC#valuetypesliveonthestack,
referencetypeobjectsliveontheheap.
InWPC#,thecommonlanguage
runtime'sgarbagecollectormanagesthe
allocationandreleaseofmemoryforanapplication.Fordevelopers,thismeans
that youdonothavetowritecodeto
performmemorymanagementtasks
whenyoudevelopmanagedapplications.
Readmorefrom:
http://msdn.microsoft.com/en-
us/library/f144e03t%28v=VS.100%29.aspx
Inadditiontogarbagecollection,
IDisposableinterfacedefinesamethodtoreleaseallocatedresources.
Readmorefrom:
http://msdn.microsoft.com/en-
us/library/system.idisposable.aspx
SymbianQtC++objectscanliveinthe
stackorintheheap.Classesthatsupport
implicitsharing(likeQImage)livealways
inheap.
SymbianQtC++doesnothavegarbagecollection.Youhavetorememberto
deleteobjects.
IftheparenttakesownershipoftheQt
C++object;parentwillautomatically
deleteitschildreninitsdestructor:
QObject* object = newQObject(parent);
IftheSymbianQtC++objecthasno
parent,youhavetoremembertodelete
theobject:
QObject* object = newQObject();
delete object;
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 64/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 64
BaseClass AllclassesinWPC#arederived
implicitlyfromObject.
Readmorefrom:
http://msdn.microsoft.com/en-
us/library/system.object%28v=VS.100%29.aspx
QObjectistheheartoftheQtC++
ObjectModel.
Readmorefrom:
http://doc.qt.nokia.com/qobject.html
ClassReference
refkeywordbeforeparametertypein
WPC#methodsignaturemeansthat
referencetoparameteriscopiedtothe
method.Thisreferencestillreferstothe
sameobjectontheheapastheoriginal
referenceusedinthecaller'sargument.
Address addr = new Address();addAddress(ref addr);
void addAddress(ref Addressaddr)
{
Console.WriteLine("Name: {0},Address: {1} added.",addr.name, addr.address);
}
outkeywordbeforeparametertypein
WPC#methodsignaturemeansthat
parametersareonlypassedbacktothe
callingfunction.Youmustassignavalue
toanoutparameterbeforeyourmethod
returns.
Address addr = new Address();
modifyAddress(out addr);
void modifyAddress(out Addressaddr)
{
addr = new Address();
addr.name = "Joe";
QtC++hasimplicitsharing.Implicitly
sharedclassesarebothsafeandefficient
whenpassedasarguments,becauseonly
apointertothedataispassedaround,
andthedataiscopiedonlyifandwhena
functionwritestoit,i.e.copy-on-write.
Readmorefrom:http://doc.qt.nokia.com/implicit-
sharing.html
Classesthatdonotsupportimplicit
sharing,likeyourownclasses,shouldbe
usedinreferenceslikeregularC++
classes.Forexample:
Address* addr = new
Address(this);
addAddress(*addr);
void addAddress(MyAddress&address)
{
}
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 65/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 65
addr.address = "C# Station";
}
Notethatthereisnopointers(*)inWP
C#.Pointersareallowedinunsafemode
only.
Readmorefrom:
http://msdn.microsoft.com/en-
us/library/8f1hz171%28v=VS.100%29.aspx
Class
Declaration
DeclaringaclassinWPC#.
MyObject myObject = newMyObject();
ObjectsarederivedautomaticallyfromObjectbaseclassandautomatically
havedefaultemptyconstructorand
destructor.
NotethatC#doesnotuseheaderfiles;all
codeiswritteninto.csfiles.
// Namespace Declarationusing System;
class MyObject
{
}
DeclaringaclassinQtC++.
MyQObject* myObject = newMyQObject (this);
#include <QObject>class MyQObject : publicQObject
{
Q_OBJECT
public:
MyQObject (QObject*parent = 0);
~ MyQObject ();
}
MyQObject:: MyQObject (QObject*parent):QObject(parent)
{
}
MyQObject::~ MyQObject ()
{
}
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 66/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 66
Polymorphism:
Baseclass
ExampleofWPC#baseclass
implementation.
public class DrawingObject
{
// virtual modifierindicates to
// derived classes that theycan
// override this method
public virtual void Draw()
{
}
}
ExampleofQtC++baseclass
implementation.
class DrawingObject : publicQObject
{
public:
DrawingObject(QObject*parent = 0);
// virtual modifierindicates to
// derived classes thatthey can
// override this method
virtual void Draw();
};
Polymorphism:
Derivedclass
ExampleofderivingbaseclassinWPC#.
public class Line :DrawingObject
{
// override modifier allowsa method
// to override the virtualmethod
// of its base class at run-time
public override void Draw()
{
}
}
Notethatmultipleinheritanceisnot
supportedinC#,althoughaclasscan
implementanynumberofinterfaces.
ExampleofderivingbaseclassinQtC++.
class Line : publicDrawingObject
{
public:
Line(QObject* parent =0);
// Overrides the virtualbase class
// method
void Draw();
};
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 67/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 67
Interfaces:
Interface
ExampleofWPC#interface.
interface ISomeInterface
{
void SomeMethodToImpl();
}
ExampleofQtC++interface.
class ISomeInterface
{
virtual void
SomeMethodToImpl();
};
Interfaces:
Implementatio
n
MyInterfaceImplimplements
ISomeInterfaceinterfaceinWPC#.
class MyInterfaceImpl
: ISomeInterface
{
public void
SomeMethodToImpl()
{
}
}
MyInterfaceImplimplements
ISomeInterfaceinterfaceinQtC++.
class MyInterfaceImpl
: public QObject,ISomeInterface
{
public:
MyInterfaceImpl(QObject*parent=0);
void SomeMethodToImpl();
};
Properties:
Defininga
property
DefiningWPC#property.
public class MyObject
{
private int m_id = 0;
// ID property
public int ID
{
get
{
return m_id;
}
set
{
m_id = value;
}
}
DefiningQtC++property.
class MyObject : public
QObject{
Q_OBJECT
// ID property
Q_PROPERTY(int id READ IDWRITE setID)
public:
MyObject(QObject*parent=0);
int ID() const;
void setID(const int);
private:
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 68/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 68
}
CallingIDproperty.
MyObject myObject = newMyObject();
myObject.ID = 100;
int i = myObject.ID;
Readmorefrom:
http://msdn.microsoft.com/en-
us/library/x9fsa0sw.aspx
int m_id;
};
CallingIDproperty.
MyObject* myObject = newMyObject();
myObject->setID(100);
int i = myObject->ID();
Properties:
Auto-
implemented
properties
WPC#hasAuto-implemented
propertiesthatcanbedeclaredina
singleline.C#compilercreatesthe
backingstorefieldbehindthescenesto
containthepropertyvalue,givingthe
samelogicthatexistswithtraditional
properties,butsavingyoufromhavingto
useallofthesyntaxofthetraditional
property.
public class MyObject
{
public int ID { get; set;}
}
CallingIDproperty.
MyObject myObject = newMyObject();
myObject.ID = 100;
int i = myObject.ID;
Readmorefrom:
http://msdn.microsoft.com/en-
us/library/bb384054.aspx
QtC++doesn’thaveAuto-implemented
properties.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 69/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 69
Struct InWPC#,astructisavaluetypewhilea
classisareferencetype.Valuetypeshold
theirvalueinmemorywheretheyare
declared,referencetypesholdareference
toanobjectinmemory.
struct MyStruct
{
// Property in the struct
public int Width { get;set; }
public void SayWidth()
{
}
}
Readmorefrom:
http://msdn.microsoft.com/en-
us/library/saxz13w4.aspx
ExampleofQtC++struct.QtC++structs
canhavemethodsbutcannothave
properties.
struct MyStruct
{
// Can't define propertyinto
// struct
//Q_PROPERTY(int widthREAD width WRITE setWidth)
private:
int m_width;
public:
void sayWidth();
int width() const;
void setWidth(const int);
};
void MyStruct::sayWidth()
{
qDebug() << m_width;}
int MyStruct::width() const
{
return m_width;
}
void MyStruct::setWidth(constint w)
{
m_width = w;
}
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 70/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 70
Exception
Handling
InWPC#,youcanhandleexceptionsin
try/catch/finallyblocks,for
example:
FileStream inStream = null;
try
{
inStream =File.OpenRead("somefile.txt");
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
if (inStream != null)
inStream.Close();
}
Readmorefrom:
http://msdn.microsoft.com/en-
us/library/ms229005.aspx
QtC++hassomeexceptionhandling
functionalitybutitisnotfullycompatible
betweenallsupportedplatforms.The
Symbianplatformimplementsitsown
exceptionsystemthatdiffersfromthe
standardC++mechanism.
EventHandling TheeventmodelintheWPC#isbasedon
havinganeventdelegatethatconnects
aneventwithitshandler.Toraisean
event,twoelementsareneeded:delegate
andeventdata.
EventHandlerisapredefineddelegate
andEventArgsisevent’sdata.
Forexample,toassociatethebuttonclickedeventwiththemethodthatwill
handletheevent(OnClick),addan
instanceofthe(EventHandler)
delegatetothe(Click)event.
Qtusessignalandslotmechanism.
Signalsandslotsareusedfor
communicationbetweenobjectsinQt
C++.
Anothermechanismtoreceiveandhandle
eventsistosubclassQObjectandtore-
implementthenecessaryeventhandling
functions.
NotethatQtsignalandslotevent
handlingmechanismisalsoaccessible
throughQMLcode.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 71/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 71
// Create Button
Button btn = new Button();
// Create event handler forButton
// Click event
btn.Click+=newEventHandler(OnClick);
public void OnClick(objectsender,EventArgs e){
// Button clicked
}
Readmorefrom
http://msdn.microsoft.com/en-
us/library/system.eventhandler.aspx
// Create Button
QPushButton* btn = newQPushButton(this);
// Listen/connect Buttonclicked()
// signal to btnClicked() slot
connect(btn,SIGNAL(clicked()), this,SLOT(btnClicked()));
void MyClass::btnClicked(){
// Slot where Button clickedsignal is
// sent
}
ComparisonbetweenC#andQtC++programminglanguagefundamentals
SeeC#LanguageSpecificationformoredetailsaboutallaspectsoftheC#programming
language.SeeC#ProgrammingGuideformoreinformationaboutC#programming.
DifferencesbetweenC#andQtC++Thefollowingtablesummarizesthemostessentialdifferencesbetweensyntaxand
featuresofC#andQtC++programminglanguages.
DifferencesbetweenC#andQtC++programminglanguages
Inheritance:C#classescanimplementanynumberofinterfaces,butcaninheritfrom
onlyonebaseclass.Furthermore,C#structsdonotsupportinheritance,anddonot
supportexplicitdefaultconstructors(oneisprovidedbydefault).InQtC++,structscan
havemethodsbutcannothaveproperties.
Arrays:InQtC++,arraysareprovidedascontainerclasses.STLcontainerscanalsobe
used.QtC++containershandlearrayobjectsaspointers(excludingcopy-on-write).InC#,arraysareobjectsthatincludemethodsandproperties.ThesyntaxfordeclaringC#
arraysisdifferentfromthatforC++arrays:thetokens"[]"appearfollowingthearray
typeinC#,notthevariable.
Booleans:InQtC++,thebooltypeisessentiallyaninteger.InQML,abooleanisa
binarytrue/falsevalue.InC#,thereisnoconversionbetweenthebooltypeandother
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 72/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 72
types.
Passingparameters:InQtC++,classesarepassedaspointersthroughimplicitsharing.
Classdataiscopiedonlyifandwhenafunctionwritestoit.InC#,classesarepassedby
referenceandstructsarepassedbyvalueunlessexplicitlypassedbyreferencewiththe
reforoutparametermodifiers.
Theswitchstatement:UnliketheQtC++switchstatement,C#doesnotsupport
fall-throughfromonecaselabeltoanother.
Delegates:C#delegatesareroughlysimilartomethodpointersinQtC++.However,
delegatesaretype-safeandsecure.
Base-classmethods:C#supportsthebasekeywordforcallingtheoverriddenbase
classmembersfromderivedclasses.Also,overridingvirtualorabstractmethodsis
explicitinC#,usingtheoverridekeyword.
Methodhiding:QtC++supportstheimplicit"hiding"ofmethodthroughinheritance.
InC#,youmustusethenewmodifiertoexplicitlyhideinheritedmembers.
Preprocessordirectivesareusedforconditionalcompilation.Noheaderfilesareused
inC#.
Exceptionhandling:C#providesthefinallykeywordtoprovideforcodethatshould
beexecutedregardlessofwhetheranexceptionisthrown.InQtC++,exception
handlingisnotfullycompatiblebetweenallsupportedplatformsanderrorcodesare
usedinsteadofthrowingexceptions.Furthermore,Symbianplatformhasitsown
TRAP/Leave/CleanupStackbasedexceptionhandlingmechanism.
C#operators:C#supportsadditionaloperatorssuchasisandtypeof.Italso
introducesdifferentfunctionalityforsomelogicaloperators.
Thetypedefkeyword:InQtC++,typedefisusedtocreateshorterormore
convenientnamesfortypesthathavealreadybeendeclared.InC#,theusingdirective
providesthiscapability.
Theexternkeyword:InQtC++,externisusedtoimporttypesandfunctions.InC#,externisusedtocreatealiasesforusingdifferentversionsofthesameassembly.
Thestatickeyword:InQtC++,staticcanbeusedbothtodeclareclass-level
entitiesandtodeclaretypesthatarespecifictoamodule.InC#,staticisonlyusedto
declareclass-levelentities.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 73/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 73
The MainmethodinC#isdeclareddifferentlyfromthemainfunctioninQtC++.InC#
itiscapitalizedandalwaysstatic.Also,supportforprocessingofcommand-line
argumentsismuchmorerobustinC#.
PointersareallowedinC#,butonlyinunsafemode.
OverloadingoperatorsisperformeddifferentlyinC#.
Strings:InQtC++astringissimplyanarrayofcharacters.InC#,stringsareobjectsthat
supportrobustsearchingmethods.
TheforeachkeywordenablesyoutoiteratethrougharraysandcollectionsinC#.
Globals:InC#,globalmethodsandvariablesarenotsupported.Methodsandvariables
mustbecontainedwithinaclassorstruct.
The#definepreprocessingdirective:InQtC++the#definedirectiveiscommonly
usedtodeclareconstantvalues.InC#the#definedirectivecannotbeusedforthis
purpose.ConstantsinC#arebestdefinedasenumeratedtypes(integralvaluesonly)or
asstaticmembersofaclassorstruct.Ifyouhaveseveralsuchconstants,consider
creatingaseparate"Constants"classtoholdthem.
Importingtypes:InQtC++,typescommontomultiplemodulesareplacedinheader
files.InC#,thisinformationisavailableviametadata.
LocalvariablesinC#cannotbeusedbeforetheyareinitialized.
Memorymanagement:QtC++isnotagarbagecollectedlanguage;memorythatis
notexplicitlyreleaseremainsallocateduntiltheprocessterminates.C#isagarbage
collectedlanguage.
Destructors:C#hasdifferentsyntaxfordeterministicallyreleasingunmanaged
resources.
Constructors:SimilartoQtC++,ifyoudonotprovideaclassconstructorinC#,a
defaultconstructorisautomaticallygeneratedforyou.Thedefaultconstructorinitializes
allthefieldstotheirdefaultvalues.
C#doesnotsupportbitfields.
C#input/outputservicesandformattingrelyontherun-timelibraryofthe.NET
Framework.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 74/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter4:C#programming 74
InC#,methodparameterscannothavedefaultvalues.Usemethodoverloadsifyou
wanttoachievethesameeffect.
InC#,generictypesandmethodsprovidefortypeparameterizationinawaythatis
similartoC++templatesinQt.Therearesignificantdifferences,however.Forexample,
inC#generictypeinformationispreservedatruntime.
Theaskeywordissimilartoastandardcast,exceptthatratherthanthrowanexception
iftheconversionfails,thereturnvalueisnull.Thisissimilartousingstatic_castin
QtC++,which,unlikedynamic_castinstandardC++,performsnorun-timecheck
andhencedoesnotthrowanexceptiononfailure.QtC++qobject_castfunction
behavessimilarlytothestandardC++dynamic_cast,withtheexceptionthatit
doesn'trequireRTTIsupportanditworksacrossdynamiclibraryboundaries.
C#forC++DevelopersprovidesmoreinformationabouthowtoadapttoC#
developmentasaC++developer.
SummaryInthischapter,welookedatC#programmingfromtheperspectiveofaSymbianQt
C++developer.C#isastronglytyped,object-orientedprogramminglanguagethatuses
staticbinding.ThemostessentialdifferencesbetweenQtC++andC#weredescribed
andvisualizedusingcomparisonsandcodesnippets.However,severalC#conceptsare
similartotheQtC++conceptssotheknowledgeofQtC++andtheobjectoriented
programmingingeneralwillhelpyoutomasterC#quickly.
RelatedResourcesTogodeeperintoC#programminglanguage,visit:
C#forC++Developers
IntroductiontotheC#language
C#LanguageSpecification
C#ProgrammingGuide
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 75/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 75
Chapter5:IntroducingWindowsPhone
ApplicationLifeCycle
TheWindowsPhone(WP)executionmodelisdesignedtoimproveuserexperienceby
cuttingdownonresponsetimeandofferingseamlessnavigationamongapplications.
Duetofundamentaldifferencesinapplicationexecutionarchitecture,WPapplication’s
lifecycledifferslargelyfromtheSymbianQtapplication’slifecycle.
ExecutingMultipleApplicationsinWindowsPhoneThefollowingchaptersdescribehowWPOSplatformexecutionmodelcontrolsthe
executionofmultipleWPapplications.
MultitaskinginWindowsPhoneandSymbianQt
Toenableseamlessnavigation,WP7activatesanddeactivatesapplicationsdynamically
bylimitingthephonetorunoneapplicationatatime.WP7prioritizestheforeground
applicationandtombstonesotheropenapplications.
Tombstonedapplicationisnotpreservedinmemory,butinformationaboutthe
applicationstateisstoredandresumedwhenWP7activatestheapplicationagain.This
WP7behaviordiffersfromSymbianQtplatform,whereseveralapplicationsmaybeup
andrunningatthesametimeandtheusermayswitchbetweenactiveapplications.
However,newlyintroducedWP7.1OSarchitectureallowssimultaneousexecutionof
multipleapplications,thusprovidingmultitaskingandapplicationswitchingfunctionality
similartoSymbianQtplatform.InWP7.1OS,applicationsaretypicallyputintoa
dormantstatewhentheusernavigatesawayfromtheapplication.
Inthedormantstate,executionoftheapplication’scodeisstopped,buttheapplication
remainsintactinmemory.Ifanapplicationisdormantandtheusernavigatesbacktothe
application,theapplicationresumesandthestateofeachpageintheapplicationis
automaticallyrestoredtothestatebeforetheusernavigatedaway.
TombstoningofApplicationsinWindowsPhoneTombstoningisaprocessthroughwhichWP7deactivatesanapplicationwhenauser
navigatesawayfromit.WP7keepsarecordofthetombstonedapplicationandstores
thelatestdataandthestateoftheapplication.Iftheuserreturnstoatombstoned
applicationbyusingthehardwareBackbutton,WP7reactivatesthisapplicationandthe
applicationcanusethepreserveddatatorestorestate.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 76/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 76
InWP7.1,whenusernavigatesawayfromtheapplication,theoperatingsystemwill
attempttoputtheapplicationintoadormantstate.Dormantstateapplicationscanbe
reactivatedandautomaticallyrestoredtothepreviousstateusingthehardwareBack
button,eitherbyusingnormalpresstoreturntoapplicationorbyusinglongpressto
activatetheapplicationswitchmechanism.WP7.1OSmayalsotombstonedormantstate
applicationsincasessuchasfreeingupmemoryforotherapplications.ThefollowingtablecomparestheapplicationexecutionbehaviorbetweenSymbianQt
andWindowsPhone7&WindowsPhone7.1.
SymbianQt
Behavior
UserActionor
Event
WindowsPhone7
Behavior
WindowsPhone7.1
Behavior
Runningapplication
ismovedtothe
backgroundbutit
remainsactive
Anincoming
phonecallorSMS
Runningapplication
isdeactivatedto
tombstonedstate
Runningapplication
isdeactivatedto
dormantstate
Runningapplication
ismovedtothe
backgroundbutit
remainsactive
Userpressesthe
Homebuttonon
thephone
Runningapplication
isdeactivatedto
tombstonedstate
Runningapplication
isdeactivatedto
dormantstate
Background
applicationismoved
toforegroundwith
thecurrentstate
Userstartsanother
applicationfrom
themultitasking
menu
Multitaskingisnot
supportedinWP7
Dormantstate
applicationismoved
toforegroundand
automatically
restoredto
preserved
applicationstate
Background
applicationismoved
toforegroundwith
thecurrentstate
Usernavigates
between
applicationsusing
theBackbutton
onthephone(ToolbarBack
buttonin
Symbian)
Tombstonedstate
applicationismoved
toforegroundand
restoredtothestate
storedduringdeactivation
Dormantstate
applicationismoved
toforegroundand
automatically
restoredtopreserved
applicationstate
Platformbehavioroncertainuseractionsandphoneevents
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 77/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 77
LifeCycleEventsofaWindowsPhoneApplicationThischapterintroducestheeventstakingplaceduringthelifecycleofaWPapplication.
Thefollowingpictureillustratesthelife-cycleandstatesofaWPapplication.
Life-cycleandstatetransitionsofaWindowsPhoneapplication
Launching
InWP,theusercanlaunchapplicationsfromtheinstalledApplicationsList,fromatileon
theStartscreen,throughatoastnotificationorthroughmenus.Anapplicationis
launchedwhenitisstartedbyothermeansthannavigatingbacktoitusingthehardware
Backbutton.Whenevertheuserlaunchesanapplication,WPcreatesanewinstanceof
theapplication.
TheLaunchingeventisraisedevenbeforeapplicationisvisibletotheuser.Inthehandler
forthisevent,youshouldexecuteaslittlecodeaspossible.Storingdataorperforming
networkoperationsatthisstatemayincreasethestartuptimeoftheapplication.Forthe
bestperformanceanduserexperience,resource-intensivetasksshouldbeperformedon
abackgroundthreadafteryourapplicationhasloaded.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 78/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 78
Running
Afterlaunching,theapplicationgoesintotheRunningstate.Inthisstate,theapplication
managesitsownstateastheusernavigatesthroughthedifferentpagesofthe
application.Applicationcontinuestorununtiltheusernavigatesforwardawayfromthe
applicationorbackwardspastthefirstapplicationpage.
IntheRunningstate,settingsandthepersistentdataaresaved.Thisreducesthedata
thatyouneedtosavewhentheapplication’sstatechanges.However,thedecisionto
savedatainthisstateisoptional.Ifthesizeofthepersisteddataisnotlarge,youdon’t
needtosavethedata.
Closing
YourapplicationcomesacrosstheClosingeventwhentheuserpressesthehardware
Backbuttonwhilelocatedintheapplication’sfirstpage.Inthehandlerforthisevent,you
cansavedatathatshouldpersistacrossinstancestotheisolatedstorage.
Thereisatimelimitof10secondsforapplicationstocompleteallapplicationandpage
navigationevents.Ifthislimitisexceeded,theapplicationisterminated.Forthisreason,
itisagoodideatosavepersistentstateduringRunningstateoftheapplicationand
avoidhavingtodolargeamountsoffileI/OintheClosingeventhandler.
Deactivating
WPdeactivatesyourapplicationinthefollowingscenarios:
Theuseropensanotherapplication
Theuserlocksthephonescreen AneventaccessestheLauncherorChooserAPIs
TheuserpressestheWindowsbuttontoopentheStartscreenonthephone
TheuserpressestheSearchbuttononthephone
InthehandlerforDeactivatedevent,youmustsaveanyapplicationstatesothatitcould
berestoredatalatertime.WindowsPhoneapplicationsareprovidedwiththeState
object,whichisanin-memorydictionaryyoucanusetostoreandrestoreapplication
statewithoutresource-intensivefileoperations.
ItispossibleforanapplicationtobecompletelyterminatedafterDeactivatedevent.
Whenanapplicationisterminated,itsstatedictionaryisnotpreserved.Forthisreason,
youshouldalsostoreanystatethatshouldbepersistedacrossapplicationinstancesto
isolatedstorageduringtheDeactivatedevent.
AftertheDeactivatedeventyourapplicationentersthedormantortombstonedstate.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 79/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 79
Activating
TheActivatedeventisraisedwhentheuserreturnstoadormantortombstoned
application.Applicationsshouldchecktheeventargumentstodeterminewhetherthe
applicationisreturningfrombeingindormantorintombstonedstate.
Iftheapplicationisreturningfromdormantstate,thestateofapplicationhasbeenautomaticallypreservedbytheWPoperatingsystem.Iftheapplicationisreturningfrom
tombstonedstate,theapplicationshouldusetheStatedictionarytorestoreitsstate
beforedeactivation.
Applicationsshouldnotperformresource-intensivetaskssuchasloadingfromisolated
storageorusingnetworkresourcesintheActivatedeventhandlerbecauseitincreases
thetimeittakesfortheapplicationtoresume.Instead,theseoperationsshouldbe
performedonabackgroundthreadaftertheapplicationhasbeenactivated.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 80/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 80
EventHandlersinWindowsPhoneApplicationsInSymbianQt,eachapplicationhasownprocessandmainthreadthatcontrols
applicationlife-cycle,resourcesandstate.Applicationexecutioniscontrolledinevent
loopbasedondifferentapplication-specificandsystem-wideeventssuchassignalsand
slots,commands,Windowserverevents,systemevents,domain-specificeventsandtouch-specificevents,mostofthemasynchronous.
WPapplicationlife-cycleislargelydifferentfromtheSymbianQtapplicationlife-cycle.In
WP,yourapplicationisintransitionbetweentheactiveandinactivestates.Youcan
implementhandlersforapplication’slife-cycleeventsandpageeventstosaveand
restoreapplication&pagestates.
ThefollowingtableintroducesWPapplicationlife-cycleevents&Pageclassevent
handlermethodscomparedtosomewhatsimilarSymbianQtmethods&events.
WindowsPhoneState
WindowsPhoneApplicationEvents
WindowsPhonePageMethods
SymbianQtEvents
Launching Application_LaunchingInitializeComponent()
QEvent::Applicatio
nActivate event
Running QObject::eventFilt
er eventloop
Deactivated Application_Deactivated
OnNavigatedFrom QEvent::Applicatio
nDeactivate event
Activation Application_Activated OnNavigatedTo QEvent::Applicatio
nActivate event
Closing Application_Closing OnNavigatedFrom QEvent::Applicatio
nDeactivate event
WPapplicationlife-cycleeventsandPageclasseventhandlermethods
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 81/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 81
InadditiontoWPapplicationlife-cycleeventsandeventhandlersintroducedinthe
previouschapter,WPapplicationpageeventscanbemanagedusingWPpageevent
handlermethods.TheInitializeComponent()methodinWPisusedinthe
constructorofthePageclasstoinitializevariables.Youneedtogetthe
Application_Launchingeventtodefinetheglobalvariablesin
InitializeComponent()method.OftheotherWPpageeventhandlingmethods,OnNavigatedTo isusedinPageclass
whenapagebecomestheactivepageinaframe.Respectively,OnNavigatedFrom
methodisusedwhenapageisnolongertheactivepageinaframe.Thesemethods
havecloserelationshipwithapplicationeventsApplication_Launching,
Application_Deactivated, Application_Activated and
Application_Closing.
TheOnNavigatedTo(NavigationEventArgs) methodinWPiscalledwhenever
theusernavigatestoanapplicationpagei.e.whentheapplicationisfirstlaunched,when
theusernavigatesbetweenthepagesoftheapplicationorwhentheapplicationisre-launchedafterbeingmadedormantortombstoned.Inthismethod,applicationsshould
checkwhetherthepageisanewinstance.Ifitisnot,statedoesnotneedtoberestored.
IfthepageisanewinstanceandthereisdataintheStatedictionaryforthepage,then
thedatashouldbeusedtorestorethestateofthepage’sUI.
TheOnNavigatedFrom(NavigationEventArgs) methodinWPiscalledwhenever
theusernavigatesawayfromanapplicationpage,asaresultofnormalpagenavigation
withinyourapplicationorwhentheapplicationisdeactivated.Wheneverthismethodis
called,yourapplicationshouldstorethepagestatesothatitcanberestorediftheuser
returnstothepage.
Implementingapplicationlife-cyclemanagementThischapterillustratestheWPapplicationlife-cyclemanagementandapplication&
pagestatehandlingonapplicationcodelevel.ForthatpurposeweuseourShoppingList
exampleapplication,WPPageclasseventhandlermethodsandIsolatedStoragefor
persistentdata.Purposeofthecodesnippetsistoprovideplainandsimpleexamplesof
IsolatedStorageandPageclasseventhandlermethodusage.
RefertopreviouschaptersandseeExecutionModelOverviewforWindowsPhoneformorecomprehensiveinformationaboutWindowsPhoneapplicationexecutionmodel
andapplication&pageeventhandling.ExecutionModelBestPracticesforWindows
Phoneprovidesusefulhintsandtipsforexecutionmodelimplementationstrategyin
yourownapplications.
SavingtheApplicationandPageStateData
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 82/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 82
TosavethepersistentstatedataofaWPapplication,youcanuseIsolatedStorage.
IsolatedStorageisasafeapplication-specificstoragespacethatisnotaccessibletoother
applications.AllWPapplicationI/OoperationsarerestrictedtoIsolatedStorageanddo
nothavedirectaccesstotheunderlyingOSfilesystemortotheIsolatedStorageof
otherapplications.ThefollowingpictureillustratestheoptionsforusingIsolatedStorage.
DatatypesthatcanbestoredtoIsolatedStorage
Toimplementthesavingofpersistentapplicationandpagestatedata,youneedto
obtaintheIsolatedStoragefortheapplication.Afterthat,createafileoruseKey/Value
pairsinIsolatedStoragetostorethepersistentstatedata.InourShoppingList example
application,wesavetheshoppinglistdatatoafile.
ToobtainIsolatedStorageandtostoretheshoppinglisttoafile,dothefollowingin
ShoppingList exampleapplication:
44.AddthefollowingusingdirectivestoyourMainPage.xaml.cstoinclude
namespacesforIsolatedStoragehandling:
using System.IO;
using System.IO.IsolatedStorage;
45.Todetermineifthepageisanewinstance,addthefollowingBooleanvariableto
theMainPageclassdefinitioninMainPage.xaml.cs.
public partial class MainPage : PhoneApplicationPage
{
bool _isNewPageInstance = false;
46.IntheconstructoroftheMainPageclass,settheisNewInstancevariableto
true.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 83/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 83
//Constructor
public MainPage()
{
InitializeComponent();
_isNewPageInstance = true;
TheconstructorwillbecalledonlywhentheuserislaunchingtheShoppingList
application.IftheuserissimplynavigatingbacktotheMainPageof ShoppingList
application,dataisnotrestored.
47.TheOnNavigatedTo methodiscalledwhenevertheusernavigatestoan
applicationpage.Addthe OnNavigatedTo implementationtoMainPage
class.UsetheBooleanvariable_isNewPageInstance todetermineifthepage
isanewinstance.IfthepageisnewandpreviousIsolatedStoragefileexists,
restorethedatafromIsolatedStoragefiletoMainPagetxtListtextbox.Refer
tothecodesnippetbelow.
protected override voidOnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// If _isNewPageInstance is true, the page constructor has been// called during application launching.
// Application data may need to be restored from the Isolated// Storage.
if (_isNewPageInstance)
{
// Obtain the Isolated Storage for the application.
IsolatedStorageFile myStorage = ewIsolatedStorageFile.GetUserStoreForApplication();
// Try to load previously saved data from Isolated Storage.// Check if file exists.
if (myStorage.FileExists("ShoppingList.dat"))
{
// Create StreamReader for Isolated Storage file and
// specify file options.StreamReader myStorageReader = new
StreamReader(myStorage.OpenFile("ShoppingList.dat",FileMode.Open));
// Read the data from Isolated Storage file and output it// to UI.
txtList.Text = myStorageReader.ReadToEnd();
//Close the StreamReader
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 84/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 84
myStorageReader.Close();
}
}
// Else, if _isNewPageInstance is false, the application is// reactivated. No need to restore application data.
// Set the _isNewPageInstance to false.
_isNewPageInstance = false;
}
48.TheOnNavigatedFrom methodiscalledwhenevertheusernavigatesaway
fromanapplicationpage.Addthe OnNavigatedFrom implementationto
MainPageclass.StoretheMainPagetxtListtextboxdatatoIsolatedStorage
file.Refertothecodesnippetbelow.
protected override voidOnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{base.OnNavigatedFrom(e);
// Store the member data to the Isolated Storage, in case the// application is never re-activated.
// Obtain the Isolated Storage for the application.
IsolatedStorageFile myStorage =IsolatedStorageFile.GetUserStoreForApplication();
// Create StreamWriter for Isolated Storage file and specify file// options.
StreamWriter myStorageWriter = newStreamWriter(myStorage.OpenFile("ShoppingList.dat",FileMode.OpenOrCreate));
// Store the UI data to Isolated Storage file.
myStorageWriter.Write(txtList.Text);
// Close the StreamReader.
myStorageWriter.Close();
}
Note:TomanagetransientapplicationandpagestatedatainWPapplications,useStatepropertyinPhoneApplicationServiceandPhoneApplicationPage classes.Statepropertyisadictionaryusedforsavingandrestoringdataduring
Application_ActivatedandApplication_Deactivatedevents.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 85/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter5:IntroducingWindowsPhoneApplicationLifeCycle 85
SummaryInthischapterwehadalookatthedifferentstatesofapplicationlifecycleinWindows
PhoneandcomparedapplicationexecutionframeworksinSymbianQtandWindows
Phone.Inaddition,WindowsPhoneapplicationlife-cycleeventsandpageeventswere
described.MethodsforeventhandlinginWindowsPhoneapplicationswerealsointroduced,aswellaspracticesforsavingapplicationandpagestatedata,bothtransient
andpersistent.
RelatedResourcesToknowmoreabouttheexecutionmodelforWindowsPhone,visit:
ExecutionModelOverviewforWindowsPhone
ExecutionModelBestPracticesforWindowsPhone
OtherResourcesyoumayfinduseful: Howto:PreserveandRestorePageStateforWindowsPhone
Howto:PreserveandRestoreApplicationStateforWindowsPhone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 86/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 86
Chapter6:PortingApplicationsto
WindowsPhone
InthepreviouschapterswehavegonethroughthebasicsofWindowsPhone(WP)
applicationdevelopment.YouhavegotanoverviewoftheWPapplicationarchitecture,
applicationdesignprinciples,developmenttoolsandtheC#programminglanguage.
Thefundamentalsareinplaceso,togetfurtherwithWPapplicationdevelopment,the
nextstepcouldwellbeportingyourfavoriteSymbianQtapplicationtoWP.
SymbianQtutilizesQtC++andJavaScriptbasedQMLasapplicationdevelopment
programminglanguageswhereasWPapplicationsareimplementedwithC#/VB.NETand
XMLbasedXAML.Theprogramminglanguagesdiffersocoderewritingisinevitably
requiredwhenportingapplicationsbetweenSymbianQtandWP.
However,therewritingofcodeisnotthattroublesomeafterall.Infact,lotsof
functionalitycanbeimplementedinWPusinglessconfiguringandlesscomplexitythan
inSymbianQt.Forsupport,youcanusetheWPAPIMappingtoolthatisahandytoolto
findoutsimilarpurposeclassesbetweenSymbianQt/QtQuickandWindowsPhone.
Furthermore,therearealotofsimilaritiesandreusablepartsinapplicationdevelopment
modelsbetweenSymbianQtandWPandyoucancertainlyporttheapplicationbusiness
logic.
Tosupportyourportingeffort,thischapterintroducessomeexampleapplicationsfrom
NokiaDeveloperthathavebeenported/rewrittenfromSymbianQttoWPC#.
Screenshots,codesnippetsandquotationsofportingconsiderationsarepresentedand,
inaddition,linkstoapplicationdistributionpagesprovidemoreinformationabout
applicationsandportingexperiencesbetweenSymbianQtandWP.Presentedexample
applicationsserveasvaluableexamplecasesthatsupportapplicationportingand
rewritingconsiderationsbetweenSymbianQtandWP.
RSSReaderExampleApplicationTheQMLRSSReaderExampleApplicationdemonstratestheusageofRSSfeedresources
fromtheInternet.ItcontainsarichUIwithviewnavigation,search,accordionlistandanimations.TheQtQuickUIcomponentsarebeingutilizedfornavigation(PageStack
andToolBar)andfordialogs&buttons.Restofthecustomcomponents&graphicsare
designedtobereusableinotherapplications.RSSReaderusestheQMLlocalstorageto
storethefeedsthattheuserhassubscribed.Theapplicationalsodemonstrateshowthe
graphicalthemecanbeswitchedfromthesettingsview.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 87/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 87
TheWPC#RSSReaderExampleApplicationisaportfromthecorrespondingSymbian
Qt/QMLexampleapplication,similarlyshowcasingtheusageofRSSfeedsandsomeWP
specificfeatures.Readtheapplicationportingstoryformoreinformation.
ThefollowingscreenshotsillustratesomeUIsofSymbianQtandWPC#RSSReader
exampleapplications.
MainviewofRSSReaderSymbianQtandWPC#versions
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 88/108
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 89/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 89
PivotItem ,theRSSitemsofthefeedareshownverysimilarlytotheQMLversion,ina
scrollablelist.FilteringthelistofitemsontheWindowsPhone7versionisdoneabit
differently;tappingthesearchbuttontakestheusertoanewscreenwiththelistofitems
andatextboxforsearching.Thedecisiontogotoaseparatepageisduetoscreenestate
concerns,astherewouldbeabittoolittleroomfortheactualRSSitemsifthesearchfield
wereonthePivotItem(especiallywhentheon-screenkeyboardisvisible).”
ThefollowingcodesnippetdemonstratesWPC#RSSReaderdatamodeldefinition
(RSSCache)anddatabindinginXAMLdocument.
<Application.Resources>
<local:RSSCache x:Key="RSSPagesDataSource" />
</Application.Resources>
...<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResourceRSSPagesDataSource}, Path=Cache}">
DinerExampleApplicationTheDinerExampleApplicationdemonstrateshowQMLcanbeusedtobuildasimple,
impressivecatalog-typerestaurantinformationapplicationforSymbianbasedonlocal
XMLdata.Itisstraightforwardtoconverttheapplicationtouseinternetresources
insteadoflocalXML-resources.Theapplicationisdesignedinawaythatitiseasyto
replacethecontentandvisualstylefordifferentrestaurants.TheapplicationutilizestheQtQuickUIcomponentsfornavigation(PageStackandToolBar)andfordialogs,
buttonsandotherGUIcontrols.
Dinerapplicationfeaturestab-basednavigation,usingtheTabGroupandToolBarQt
QuickUIcomponents.TheUIisimplementedusingmostlytheQtQuickprovided
SymbianplatformspecificUIcomponents,butitalsohassomecustomgraphicsandUI
elements,whicharedesignedtobereusableinotherapplications.Thebookingviewalso
introducestheexperimentalcom.nokia.extras-components,namelytheDatePicker
andtheTimePickerdialogs.
TheWPC#DinerExampleApplicationisaportfromthecorrespondingSymbian
Qt/QMLexampleapplication,similarlydemonstratinghowtobuildasimple,catalog-
typeapplicationforWPbasedonlocalXMLdata.Readtheapplicationportingstoryfor
moreinformation.
ThefollowingscreenshotsillustratesomeUIsofSymbianQtandWPC#Dinerexample
applications.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 90/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 90
MainviewofDinerSymbianQtandWPC#versions
LocationviewsofDinerSymbianQtandWPC#versions
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 91/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 91
ReservationviewofDinerSymbianQtandWPC#versions
ThefollowingquotationfromWPC#Dinerportingstorydescribesthedesign
considerationswhenportingDinerfromSymbianQttoWPC#.
“ChangestodesignWhenexaminingQMLDinerapp,itisapparentthatstraight-forwardportingofthe
look&feeltotheWindowsPhoneenvironmentisnotsensible.TheQMLversionfeaturesa
vividcolorthemethatisagainstWindowsPhonedesignguidelines.Also,thenavigation
modeloftheQMLversionisbasedonusingatabbarcontrolforwhichnodirect
equivalentisavailableinWindowsPhone.Thereforeadecisionwasmadenottoattempt
toportthelook&feeloftheapplicationtoWindowsPhone.Insteadanewapplication
thememoreclosetootherWindowsPhoneapplicationswasdesignedandanew
navigationmodelbasedonpanoramacontrolwasintroduced.Theportingaspectofthe
projectwasnotcenteredonlook&feelbutonthefeaturesoftheapplication.Thelook&feelofpanorama-basedapplicationsisdominatedbythebackgroundimageof
thepanorama.Forthisreason,specialattentionwasgiventotheselectionofthe
backgroundimage.TobeinaccordancewiththedarkdefaultthemeofWindowsPhone,a
relativelydark,warm-colored,andrestaurant-themedimagewasselected.Awhitetext
colorwasselectedfortheapplication,alsobecauseofthedarkthemeofWindowsPhone.
Thisselectionofadarkbackgroundimageandoverallthememeansthatthedefault
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 92/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 92
platformthemeisoverridden:eveniftheuserisusingalightWindowsPhonetheme,Diner
appstillfeaturesadarktheme.
Asasmallerdetail,orientationswitchingisamajordesigngoalintheQMLapplication.In
theWindowsPhoneenvironment,orientationswitchingisrecommendedtobeusedonlyin
viewsthatrequireuserinputwhiletheuser'sdeviceisequippedwithaphysicalkeyboard.
Forthisreason,theWindowsPhoneversionoftheapplicationislockedtoportraitmodeinallviewsexceptfortheviewformakingreservations.”
ThefollowingcodesnippetdemonstrateshowparsingofXMLfilecontainingrestaurant
dataisdoneinWPC#DinerusingLINQ.
XElement menu = doc.Descendants("menu").First();
Restaurant.Categories =
(from category in menu.Descendants("category")
select new Category()
{
Id = category.Attribute("id").Value,
Name = category.Attribute("name").Value,
IconURI = category.Attribute("icon").Value,
Dishes = (from dish in category.Descendants("dish")
select new Dish()
{
Name = dish.Attribute("name").Value,
Text = dish.Value
}).ToList<Dish>()
}).ToList<Category>();
Thefollowingcodesnippetdemonstrateshowloadingandsavingofreservationsinto
IsolatedStoragefileisimplementedinWPC#Diner.
private void LoadReservations()
{
using (IsolatedStorageFile file =IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = newIsolatedStorageFileStream("reservations.dat",
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 93/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 93
System.IO.FileMode.OpenOrCreate, file))
{
if (stream.Length > 0)
{
DataContractSerializer serializer = newDataContractSerializer(
typeof(ObservableCollection<Reservation>));
Restaurant.Reservations = serializer.ReadObject(stream) asObservableCollection<Reservation>;
}
}
}
}
private void SaveReservations()
{
using (IsolatedStorageFile file =IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = newIsolatedStorageFileStream("reservations.dat",System.IO.FileMode.Create, file))
{
DataContractSerializer serializer = newDataContractSerializer(typeof(ObservableCollection<Reservation>));
serializer.WriteObject(stream, Restaurant.Reservations);
}
}
}
SudokumasterExampleApplicationSudokumasterisalogic-based,combinatorialnumber-placementpuzzlewithnine3x3
gridseachcontainingallthedigitsfrom1to9.Inthebeginningonlysomeofthe
numbersareplacedinthegridsandtheplayerneedstofigureoutthecorrectpositionsforthemissingnumbers.
SudokumasterwasoriginallydevelopedforSymbianplatforms.Lateron,QtQuick
versionoftheSudokumasterwasimplementedandthenQtQuickversionwasrewritten
toWPSilverlightSudokumaster.ReadtheportingstoryofSudokumasterWPSilverlight
versionformoreinformation.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 94/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 94
ThefollowingscreenshotsillustratesomeUIsofSymbianQtandWPSilverlight
Sudokumasterexampleapplications.
MainviewsofSudokumasterSymbianQtandWPSilverlightversions
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 95/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 95
SpinningwaitnoteinSudokumasterSymbianQtandWPSilverlightversions
ThefollowingcodesnippetdemonstrateshowtheSudokumasterpuzzleisgenerated
usingnewthreadfromThreadPoolinWPC#Sudokumaster.
private void NewGame()
{
...
// Display wait note (spinning circle)
waitIndicator.Visibility = System.Windows.Visibility.Visible;
waitIndicator.StartSpin();
...
// Disable databinding while generating puzzle
DataContext = null;
// Puzzle generation takes couple of seconds, do it in another thread
ThreadPool.QueueUserWorkItem(dummy =>
{
// generating puzzle doesn't touch UI so it can run on another thread
game.GeneratePuzzle();
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 96/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 96
// switching to UI thread to modify UI components
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
DataContext = game.Model; // let's turn on databinding again
gameTimer.Start();
gameStartTime = DateTime.Now;
gameState = GameState.Ongoing;
UpdateStatus();
waitIndicator.Visibility = System.Windows.Visibility.Collapsed;
waitIndicator.StopSpin();
});
});
...
}
InSymbianQtSudokumaster,newthreadiscreatedusingQMLWorkerScript.
WorkerScript {
id: puzzleWorker
source: "gameLogic.js"
onMessage: {
Functions.numbers = messageObject.board;
empties = messageObject.boardEmpties;
boardChanged();
viewLoader.close();
gameOn = true;
mainBoard.focus = true;
mainTimer.start();
}
}
// gamelogic.js
WorkerScript.onMessage = function(message) {
generatePuzzle(message.rands);
WorkerScript.sendMessage({board: numbers, boardEmpties: empties});
}
Thefollowingcodesnippetsdemonstrat ehowSudokumaster’swaitnoteanimationis
implementedinWPC#XAMLandSymbianQtQMLrespectively.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 97/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 97
WPC#XAML:
<Rectangle.Resources>
<Storyboard x:Name="spinAnimation">
<DoubleAnimation
Storyboard.TargetName="Transform"
Storyboard.TargetProperty="Angle"
By="360"
Duration="0:0:0.5"
AutoReverse="False"
RepeatBehavior="Forever" />
</Storyboard>
</Rectangle.Resources>
SymbianQtQML:NumberAnimation on rotation {
id: animation
loops: Animation.Infinite
from: 0
to: 360
duration: 1500
}
Match’emPokerExampleApplicationMatch'emPokerisarcade-stylematch-Ngamewithpokerhandsinasquare-grid.Player
canchangethepositionoftwocardswithoutanylimitations.Whena"pokerhand"is
formed,itwilldestroyitselffromthelevelandscoresareadded.Blockswilldropifthere
isemptyspacebelowthem.
Match'emPokerwasoriginallyimplementediniOSandportedtoSymbianQtutilizing
QtGameEnablerthatenablestheuseofnativeOpenGLES2.0codewithinaQt
applicationinsteadofQt’sQtOpenGLrendering.SymbianQtMatch'emPokerincludes
theSVGicon,resourcecollectionfiles,gameengineandOpenGLES2.0graphics.
SymbianQtMatch’emPokerwaslaterportedtoWPXNAMatch’emPokerthatusesXNA
GameStudioandSpriteBatchbasedrendering.Theobjectivewastoportthe
applicationwithminimaleffort:reusingalloftheoriginalassetsandmodifyingthecode
aslittleaspossible.ReadtheportingstoryofMatch’emPokerWPXNAversionformore
informationaboutobservationsduringportingeffort.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 98/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter6:PortingApplicationstoWindowsPhone 98
ThefollowingscreenshotsillustratesomegameviewsfromSymbianQtandWPXNA
Match’emPokerexampleapplications.
GameviewsfromMatch'emPokerSymbianQtandWPXNAversions
SummaryInthischapterweinspectedapplicationportingbetweenSymbianQtandWPC#
throughfourexistingexampleporting/rewritingcases.ExampleportingcasescoveredseveralapplicationareaswithinSilverlightandXNAframeworksandincluded
functionalitysuchasapplicationUIcontrols,databinding,navigation,datamanagement,
threading,animationsandgraphics.Applicationdesignportingconsiderationswerealso
presented.
RelatedResourcesToknowmoreaboutthebefore-mentionedandotherexampleapplicationsportedfrom
SymbianQttoWindowsPhone,visit:
NokiaDeveloper:WindowsPhone-Codeexamples
OtherResourcesyoumayfinduseful:
MSDN:PortingYourApplicationtoWindowsPhone
AppHub:PortingYourApporGametoWindowsPhone
NokiaDeveloper:DocumentationandResourcesforWindowsPhone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 99/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter7:WindowsPhoneExampleApplications 99
Chapter7:WindowsPhoneExample
Applications
Aswehaveseeninthepreviouschapters,theWindowsPhone(WP)application
architectureandapplicationdesigndiffersfromtheSymbianQtapplicationarchitecture.
Eventhoughseveralsimilaritiesexistandmanypartsofexistingworkcanbereused
duringtransitionfromSymbianQtC++applicationstoWPC#applications,thereare
alsosomeapplicationareaswherefundamentaldifferencesexistand/orcomparisons
betweenSymbianQtC++andWPC#arehardtoexpress.
Wetrytoaddressthoseareasbyintroducingasetofexampleapplicationsthatassistin
bindingSymbianQtC++andWPC#applicationdevelopmentclosertoeachother.This
chapterpresentsWPC#exampleapplicationsonApplicationUI,deviceintegration,
networkinganddatamanagementarea.FullapplicationcodeisprovidedtoillustrateWP
C#programmingconceptsonbefore-mentionedapplicationareas,inadditionto
showcasingcommonstructuresofWPC#applicationsandtopicsintroducedinthe
previouschapters.
Anotherpurposeistoprovidemorepractical-orientedapproachtothetransitionfrom
SymbianQtC++toWPC#applicationdevelopment.Ready-madeexampleapplications
ofgoodqualityandcoveringseveralusecasesshowyouthepreferredwayof
implementingcertainfeaturesinWPC#applications.
WindowsPhoneGeneralExamplesThefollowingtablelistsgeneralpurposeexampleapplicationsforWindowsPhone.
TheseexampleapplicationandstarterkitsdemonstratemanyessentialfeaturesinWP
applicationdevelopment.
Application Description Relatedinformation
ExecutionModel
Sample
Thissampleillustratesatechnique
forpreservingandrestoringUIand
applicationstateastheapplicationisactivatedanddeactivatedbythe
operatingsystem.
ExecutionModelOverviewfor
WindowsPhone
UnitConverterStarter
Kit
Thisstarterkitdemonstrateshow
toapplytheModel-View–
ViewModeldesignpatternin
UnitConverterStarterKitfor
WindowsPhone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 100/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter7:WindowsPhoneExampleApplications 100
Application Description Relatedinformation
WindowsPhoneapplication,how
tooptimizeapplicationstartup
andhowtocreateacontext
sensitivemenu.
LevelStarterKit
Thisstarterkitdemonstrateshow
tomakeWindowsPhone
application'scolorschemematch
theuser'sthemechoice,howto
makeSilverlightapplication
interactrealisticallywiththe
accelerometerofthephoneand
howtocustomizephone
orientationsensing.
LevelStarterKitforWindows
Phone
TranslatorStarterKit
Thisstarterkitdemonstrateshow
tocallawebservice,howtousean
XNAFrameworkAPIfromwithina
Silverlightapplicationtoplaya
sound,howtomaintainahistory
listinisolatedstorageandhowto
animateanimageina
ToggleButton.
TranslatorStarterKitforWindows
Phone
WindowsPhoneApplicationUIExamplesThefollowingtablelistsexampleapplicationsfromWindowsPhoneCodeSamples
demonstratinghowtoimplementseveralWPapplicationUIconcepts.
Application Description Relatedinformation
BackStackNavigation
Sample
Thissampleshowshowtovisualize,
inspectandmodifythenavigation
history,orbackstack,ofan
application.Thissampleusesthe
newBackStackpropertyandthe
RemoveBackEntry() method
availableinWindowsPhoneOS7.1.
HowTo:NavigateUsingtheBack
StackforWindowsPhone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 101/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter7:WindowsPhoneExampleApplications 101
Application Description Relatedinformation
ApplicationBarSample
Thissampleenablesyouto
dynamicallytestthedifferent
ApplicationBarproperties,such
asOpacityandModeaswellasdifferentcolors.Thissample
containsapplicationbarcodefora
plainpage,apivotpageanda
panoramapage.
Walkthrough:Creatingan
ApplicationBarTestApplication
forWindowsPhone
Silverlight/XNA
FrameworkSample
ThissamplecombinesSilverlight
andtheXNAFrameworkintoa
singleWindowsPhoneapplication.
Thissampledemonstrateshowto
renderSilverlightcontrolsandtextfromtheXNAFrameworkbyusing
theUIElementRendererclass.
Howto:CombineSilverlightand
theXNAFrameworkinaWindows
PhoneApplication
MyLittleTeapotSample
TileSample
Thissampledemonstrateshowto
create,updateanddelete
secondaryTiles.TheTileupdates
demonstratehowtoupdatethe
propertiesonboththefrontand
backofaTile.Theupdate
techniquescanalsobeappliedto
ApplicationTiles.
TilesOverviewforWindows
Phone
ShellTileScheduleSample
TileNotification
Sample
Thissampledemonstrateshowto
updateaTileusingtheMicrosoft
PushNotificationService.This
samplecontainstwoprojects–one
projectfortheclientcodethatsets
uptheWindowsPhonedeviceto
receiveanotificationandanotherprojectthatsendsthenotification
totheMicrosoftPushNotification
Service
PushNotificationsforWindows
Phone
ToastNotificationSample
RawNotificationSample
ScheduledNotification
Sample
Thissampleshowshowtousethe
ScheduledActionServiceto
Howto:CreateAlarmsand
RemindersforWindowsPhone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 102/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter7:WindowsPhoneExampleApplications 102
Application Description Relatedinformation
scheduleandmanageReminders.
Remindersaredialogsthatpopup
anddisplayamessagetotheuser
atatimescheduledbythe
applicationthatcreatedthem.
WindowsPhoneDeviceIntegrationExamplesThefollowingtablelistsexampleapplicationsfromWindowsPhoneCodeSamples
demonstratinghowapplicationscanintegratewithdevicehardwareandplatform.
Application Description Relatedinformation
BackgroundAudio
PlayerSample
ThissampleimplementsanAudioPlayerAgentthatallows
audiotoplayevenwhenthe
applicationisnotinthe
foreground.Thisbackgroundagent
willrununderthelockscreen
wheretheusercancontrolthe
audiousingtheuniversalvolume
control(UVC).
Howto:PlayBackgroundAudio
forWindowsPhone
BackgroundAudioOverviewfor
WindowsPhone
DeviceStatusSample
ThissampledemonstrateshowtousetheDeviceStatus,including
accessingthepropertiesofthe
class,todetermineifthepower
sourceofthedevicehaschanged
andtodetermineifaphysical
keyboardhasbeendeployed.
Howto:UsetheDeviceStatus
ClassforWindowsPhone.
BasicCameraSample
Thissampledemonstrateshowto
activatetheshutterandautofocus
forcamera,howtoconfigure
pictureresolutionandflashsettings
andhowtousethehardware
shutterbutton.Thissamplealso
demonstratestouchfocusanda
front-facingcameraforthedevices
Howto:CreateaBaseCamera
ApplicationforWindowsPhone
CameraColorConversion(YCbCr
toARGB)forWindowsPhone.
Howto:WorkwithGrayscaleina
CameraApplicationforWindows
Phone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 103/108
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 104/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter7:WindowsPhoneExampleApplications 104
Application Description Relatedinformation
displayingcontactphotos.
LocalDatabaseSample
OnWindowsPhoneOS7.1,you
canuseLINQtoSQLtostore
relationaldatainalocaldatabase
thatresidesinyourapplication’s
isolatedstoragecontainer.This
sampleisato-dolistapplication
thatusesamulti-tablelocal
database.Itemsthatappearinthe
listareadded,updatedanddeleted
fromalocaldatabase,wherethey
willpersistbetweenapplication
launches
Howto:CreateaLocalDatabase
ApplicationwithMVVMfor
WindowsPhone
BingMapsSample
Thissampledemonstrateshowto
usethebasicfunctionalityofthe
BingMapsSilverlightControlfor
WindowsPhone.
BingMapsSilverlightControlfor
WindowsPhone
LocationService
Sample
Thissampleapplicationreceives
datafromtheMicrosoftLocation
Serviceanddisplaysgeographic
coordinatesofthedevice.
LocationforWindowsPhone
SearchExtensibility
Sample
SearchExtrasareanewwayfor
applicationstoseamlesslyextend
theSearchexperienceonWindows
Phone.Learnhowtointegrateyour
applicationwithsearchresultitem
cards.Thissampleisafictitious
productrecallapplicationthatyou
canlaunchfromtheextraspivot
pageofanitemcardfroma
productsearch.Ifyoudonothave
aWindowsPhoneOS7.1device,
edittheDefaultTaskelementin
theapplicationmanifestto
simulateaSearchExtrascallinthe
SearchExtensibilityOverviewfor
WindowsPhone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 105/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter7:WindowsPhoneExampleApplications 105
Application Description Relatedinformation
emulator.
WindowsPhoneNetworkingExamplesThefollowingtableintroducestwoexampleapplicationsfromWindowsPhoneCode
Samplesdemonstratingmulticastgroupcommunicationanduseofsockets.
Application Description Relatedinformation
MulticastSockets
Sample
Thissampledemonstrateshowto
communicateoveramulticastgroup
inaWindowsPhoneapplication.It
implementstheclassicRockPaper
Scissorsgame.Playersjoinamulticastgrouptodiscovereach
other.UDPunicastingisthenused
tochallengeaplayerandplaythe
actualgame.TheUdpAnySourceMulticastClient
classavailableinWindowsPhoneOS
7.1isusedinthissample.
Howto:SendandReceiveDatainaMulticastGroupfor
WindowsPhone.
Tic-Tac-ToeOver
SocketsSample
Thissampledemonstratestheuseof
socketsinaWindowsPhoneapplicationtocommunicatewitha
servicehostedonthenetwork.It
usesthenew
System.Net.Socketsclass
availableonWindowsPhone.
SocketsforWindowsPhone
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 106/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter7:WindowsPhoneExampleApplications 106
SummaryInthischapterwetookalookatseveraltypesofWindowsPhoneexampleapplications.
Lotsofessentialfunctionality,featuresandusecaseswithinApplicationUI,device
integration,datamanagementandnetworkingareaswerecoveredwiththesesample
applications.
RelatedResourcesToknowmoreabouttheexampleapplicationsandgetstartedwithapplication
developmentforWindowsPhone,visit:
WindowsPhoneDevelopmentQuickStarts
WindowsPhoneTrainingKit
OtherResourcesyoumayfinduseful:
AppHubcontentcatalog AppHubgamedevelopment
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 107/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
Chapter8:UsingtheAPIMappingTool 107
Chapter8:UsingtheAPIMappingTool
What’stheAPIMappingtoolWindowsPhone7APImappingtoolhelpsdevelopersfindtheirwayaroundwhenthey
discovertheWindowsPhoneplatform.ThinkoftheAPImappingtoolasbeinglikea
translationdictionary.Forexample,let'ssaythatyou'replanningavacationtoFrance.
Sinceyoudon'tspeakthelanguage,you'llbringapockettraveldictionary.Havingthis
toolwillsurelyhelpyoutogetsomeideaaboutwhatyouareorderingfromarestaurant
menubutyou'llhavenoideawhattheactualrecipeis-norwillyoubeabletohavea
conversioninFrenchwiththeserver!Butthat'sagreatlearningtooltomakethefirst
steps.
Withthistool,developerscangrabtheirapps,pickouttheAPIcalls,andquicklylookup
theequivalentclasses,methodsandnotificationeventsinWP7.AdevelopercansearchagivenAPIcallandfindtheequivalentWP7alongwithlinkstotheAPIdocumentations
forbothplatforms.AllWP7APIdocumentationsarepulledinfromtheSilverlight,C#
andXNAsourcesonMSDN.
HowtousethetoolForthisfirstiterationofthemapping,we’vefocusedonthecorelibrariesforQt4.7for
Symbian(QtCore,QtGui,QtLocation,QtNetwork,QtSensors,QtSql,QtXml,QtWebKit,QMLElements,QMLComponents).
Goto:http://wp7mapping.interopbridges.com/
Andyoustartbysimplybrowserthetreeontheleftpane.Oneyou’vereachamapped
item,you’llseeontherightpanetheequivalentclass/method/eventwithlinkstoboth
QtandWindowsPhone7documentation.
8/3/2019 Windows Phone Guide for Symbian Qt Application Developers Formated
http://slidepdf.com/reader/full/windows-phone-guide-for-symbian-qt-application-developers-formated 108/108
WindowsPhoneGuideforSymbianQtApplicationDevelopers
QttoWindowsPhoneAPIMappingTool:http://wp7mapping.interopbridges.com/
What'snext?
Ofcourse,thisisaworkinprogress,coveragewillexpandandmoreAPIswillbemappedsoon.So,pleaseconsiderusingthemappingtoolinyourportingefforts,andprovide
feedbackonthededicatedforum,whereyoucanalsosuggestnewmappingAPIsto
include:http://wp7mapping.uservoice.com