About This Book, Unleash the power of Qt 5 with C++14Integrate useful third-party libraries such as OpenCVPackage and deploy your application on multiple platforms, Who This Book Is For, This book will appeal to developers and programmers who would like to build GUI-based applications. Knowledge of Table of contentsMastering Ot 5Creditsabout the authorsabout the reviewerwww.Packtpub.comWhy subscribe?PrefaceWhat this book coversWhat you need for this bookWho this book is forConventionsReader feedbackCustomer supportDownloading the example codeErrataracyQuuestionsGet Your Qt Feet Wetcreating a projectMain Window structureDesignerSignals and slotsCustom WIdgetAdding a taskUsing a DIalogDistributing code responsibilityEmitting a custom signal using lambdasSimplifying with the auto type and a range-based for loopSummary2. Discovering QMake Secretsesigning a cross-platform projectAdding the windows implementationAdding the Linux implementationAdding the Mac os implementationTransforming SysInfo into a singletonExploring ot ChartsCpu Widget using CHartsMemory using chartsThe pro file in depthUnder the hood of gmakeBeneath Q OBJECT and signals/slotsSummary3. Dividing Your Project and Ruling Your CodeDesigning a maintainable projectDefining data classesStoring your data in a databaseProtecting your code with a smart pointerImplementing the modelSummar4. Conquering the Desktop UICreating a GUI linked to a core shared libraryListing your albums with AlbumListWidgetCreating a ThumbnailProxyModelDisplaying the selected album with Album WidgetEnhancing thumbnails with PictureDelegateDisplaying a picture with Picture WidgetComposing your gallery appSummary5. Dominating the mobile uxStarting with Qt Quick and QMLChecking your development environmentCreating a Qt Quick projectPreparing your Qt Quick gallery entry pointDisplaying albums with ListViewTheming the application with a QML singletonLoading a database on mobileCreating a new album from a custom InputDialogLoading images with an ImageproviderDisplaying thumbnails in a GridViewSwiping through full resolution picturesSummary6. Even Ot Deserves a Slice of Raspberry piDiscovering otBConfiguring Qt for your Raspberry piCreating an entry point for your ot3D codeSettingthe sceneAssembling your ot3D entitiesPreparing the board gameCrafting entities from the factoryBuilding a snake engine in JavaScriptvarying the hud with QML statesProfiling your Qml applicationSummary7. Third-Party Libraries Without a HeadacheCreating your Qt Designer pluginConfiguring the project for WindowsConfiguring the project for LinuxConfiguring the project for MacImplementing your OpenCV filtersDesigning the uI with Filter WidgetExposing your plugin to Qt DesignerUSing your ot designer pluginBuilding the image-filter applicationSummary8. Animations -Its alive. alivePreparing an SDKCreating your pluginsLoading your plugins dynamicallyUsing the plugins inside the applicationDiscovering the Animation FrameworkMaking your thumbnails jumpFading the picture inFlashing the thumbnail in a sequenceSummary9. Keeping Your Sanity with MultithreadingDiscovering QThreadFlying over Qt multithreading technologiesArchitecting the mandelbrot proiectDefining a Job class with RUnnableUsing Qthread Pool in MandelbrotcalculatorDisplaying the fractal with MandelbrotwidgetSummary10. Need ipc? Get your minions to workArchitecturing an IPC projectLaying down the foundations with an SDKWor king with QData Stream and QTcp SocketInteracting with sockets in the workerInteracting with sockets from the applicationBuilding your own QTcpServerummar11. Having Fun with SerializationArchitecting the drum machine projectCreating a drum trackMaking your objects serializable with Q variantSerializing objects in JSON formatSerializing obiects in XML formatSerializing objects in binary formatTriggering a QButton with your keyboard ectPlaying low latency sounds with QSoundEfftBringing playback Worker to lifeAccepting mouse drag and drop eventsSummary12. You Shall(not Pass with QTestDiscovering Qt TestExecuting your testsWriting factorized tests with datasetsBenchmarking your codeTesting your GUISpying on your application with QSignalSpySummary13. all Packed and ready to deployPackaging your applicationPackaging for WindowsPackaging for Linux with a distribution packagePackaging for Linux with ApplmagePackaging for Mac OSXPackaging for AndroidPackaging for iOSSummary14.Qt Hat Tips and TricksManaging your workspace with sessionsSearching with the Lo catorIncreasing the compilation speedExamining the memory with Qt CreatorGenerating random numbersSilencing unused variable warningsLogging custom objects to Q DebugImproving log messagesSaving your logs to a fileGenerating a command-line interfaceSending and receiving Http dataummarMastering Qt 5Mastering Qt 5Copyright C 2016 Packt PublishingAll rights reserved. No part of this book may be reproduced, stored in a retrieval system, ortransmitted in any form or by any means, without the prior written permission of thepublisher, except in the case of brief quotations embedded in critical articles or reviewsEvery effort has been made in the preparation of this book to ensure the accuracy of theinformation presented However, the information contained in this book is sold withoutwarranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealersand distributors will be held liable for any damages caused or alleged to be caused directly orindirectly by this bookPackt Publishing has endeavored to provide trademar k information about all of thecompanies and products mentioned in this book by the appropriate use of capitals. However,Packt Publishing cannot guarantee the accuracy of this informationFirst published December 2016Production reference: 1121216Published by Packt Publishing LtdLivery place35 Livery streetBirminghamB3 2PB. UKISBN978-1-78646-7126www.packtpub.comCreditsAuthorsCopy EditorGuillaume lazarSafis EditingRobin PenaReviewerProject CoordinatorRay RischpaterIzzat ContractorCommissioning EditorProofreaderKunal parikhSafis EditingAcquisition EditorIndexerSonali vernekarRekha nairContent Development Editor Production CoordinatorRohit Kumar singhAparna BhagatTechnical editorVivek Palabout the authorsdifferent companies, from startups to multinationals for the last 7 years. He took theGuillaume lazar is a software engineer living near Paris in France. He has wor kedopportunity to observe and learn from many team organizations and technologiesHe eventually founded his own software development company, NeuronalMotion, at the ageof 27 with his friend robin Penea in 2014. Information about it and its open source projectscanbefoundonthecomapny'swebsitewww.neuronalmotion.comNeuronalMotion represents to guillaume "a different way of working The currenthierarchical organization that applies to most companies seems obsolete to him. with his owncompany, he wants to try something different, where each employee will be autonomousAlthough he defines himself as a Qt framework lover, he likes to mix different technologiesand platforms. He also spends time on game development, machine learning, and electronics,because things"become alive.Creating examples and writing chapters for this book was a serious challenge this year.Some sections were fundamentally changed to match Qt evolution. I would not have beenable to achieve this task alone. I wish to thank robin Penea, my friend and the coauthorof this book. He gave his all to create with me a robust Qt book with modern C++. Ourreview team, Rohit Kumar Singh, Ray Rischpater, Quentin Canu, Chistophe Dongieux, andHugo loi have done excellent work: they corrected us and raised some important issuesi also want to thank packt for the good follow up during the writing process. Finally, Ithank my family and, particularly, Sophie, my girlfriend, for her supportRobin Penea is a software engineer living in France. He has worked for several companiesover the last 7 years, on many different technolo gies (ranging from server applicationdevelopment to embedded programmingHe founded NeuronalMotion with guillaume lazar in 2014 to implement his vision ofentrepreneurship and project development. He aims to achieve a self-organized companyMoreinformationisavailableatwwwneuronalmotion.comBesides developing with Qt, he likes to tinker with the Android AosP framework, learn newprogramming language paradigms, and discover how to interweave technology and real lifehis book would not have existed without Guillaume Lazar, my friend and the coauthor ofthe book. He was truly dedicated to designing and crafting the best possible book. I wishto thank our reviewers, Rohit Kumar Singh, Ray Rischpater, Quentin Canu, ChristopheDongieux, and Hugo Loi. Their input was invaluable and definitely raised the quality ofthe book. Packt played a sensible role, listening to our requests and changes, guiding us