Qt5 Cadaques Release Master

Total Page:16

File Type:pdf, Size:1020Kb

Qt5 Cadaques Release Master Qt5 Cadaques Release master JRyannel,JThelin December 07, 2020 at 10:51 CET CONTENTS 1 Meet Qt 5 3 1.1 Preface................................................3 1.2 Qt 5 Introduction...........................................4 1.3 Qt Building Blocks..........................................9 1.4 Qt Project............................................... 11 2 Get Started 13 2.1 Installing Qt 5 SDK......................................... 13 2.2 Hello World............................................. 13 2.3 Application Types.......................................... 15 2.4 Summary............................................... 23 3 Qt Creator IDE 25 3.1 The User Interface.......................................... 25 3.2 Registering your Qt Kit....................................... 26 3.3 Managing Projects.......................................... 26 3.4 Using the Editor........................................... 27 3.5 Locator................................................ 27 3.6 Debugging.............................................. 28 3.7 Shortcuts............................................... 28 4 Quick Starter 31 4.1 QML Syntax............................................. 31 4.2 Basic Elements............................................ 36 4.3 Components............................................. 41 4.4 Simple Transformations....................................... 43 4.5 Positioning Elements......................................... 46 4.6 Layout Items............................................. 51 4.7 Input Elements............................................ 53 4.8 Advanced Techniques........................................ 58 5 Fluid Elements 59 5.1 Animations.............................................. 59 5.2 States and Transitions........................................ 74 5.3 Advanced Techniques........................................ 78 6 Qt Quick Controls 2 81 6.1 Introduction to Controls....................................... 81 6.2 An Image Viewer........................................... 83 6.3 Common Patterns.......................................... 97 6.4 The Imagine Style.......................................... 114 6.5 Summary............................................... 118 7 Model-View-Delegate 121 7.1 Concept................................................ 121 i 7.2 Basic Models............................................. 122 7.3 Dynamic Views............................................ 126 7.4 Delegate............................................... 135 7.5 Advanced Techniques........................................ 145 7.6 Summary............................................... 156 8 Felgo 159 8.1 Why choose Felgo?......................................... 159 8.2 Installing Felgo............................................ 161 8.3 Hello World with Felgo....................................... 162 8.4 A Messaging App.......................................... 163 8.5 Advanced Topics........................................... 173 8.6 Summary............................................... 183 9 Canvas Element 185 9.1 Convenient API........................................... 187 9.2 Gradients............................................... 188 9.3 Shadows............................................... 189 9.4 Images................................................ 189 9.5 Transformation............................................ 191 9.6 Composition Modes......................................... 192 9.7 Pixel Buffers............................................. 193 9.8 Canvas Paint............................................. 194 9.9 Porting from HTML5 Canvas.................................... 196 10 Particle Simulations 203 10.1 Concept................................................ 203 10.2 Simple Simulation.......................................... 204 10.3 Particle Parameters.......................................... 206 10.4 Directed Particles........................................... 207 10.5 Particle Painters........................................... 210 10.6 Affecting Particles.......................................... 212 10.7 Particle Groups............................................ 217 10.8 Summary............................................... 224 11 Shader Effects 225 11.1 OpenGL Shaders........................................... 225 11.2 Shader Elements........................................... 226 11.3 Fragment Shaders.......................................... 228 11.4 Wave Effect.............................................. 232 11.5 Vertex Shader............................................. 233 11.6 Curtain Effect............................................ 243 11.7 Qt GraphicsEffect Library...................................... 246 12 Multimedia 249 12.1 Playing Media............................................ 249 12.2 Sound Effects............................................. 251 12.3 Video Streams............................................ 252 12.4 Capturing Images........................................... 253 12.5 Advanced Techniques........................................ 255 12.6 Summary............................................... 256 13 Networking 257 13.1 Serving UI via HTTP......................................... 257 13.2 Templating.............................................. 260 13.3 HTTP Requests............................................ 260 13.4 Local files.............................................. 263 13.5 REST API.............................................. 264 13.6 Authentication using OAuth..................................... 269 ii 13.7 Web Sockets............................................. 270 13.8 Summary............................................... 276 14 Storage 277 14.1 Settings................................................ 277 14.2 Local Storage - SQL......................................... 278 14.3 Other Storage APIs.......................................... 282 15 Dynamic QML 283 15.1 Loading Components Dynamically................................. 283 15.2 Creating and Destroying Objects................................... 288 15.3 Tracking Dynamic Objects...................................... 291 15.4 Summary............................................... 293 16 JavaScript 295 16.1 Browser/HTML vs QtQuick/QML.................................. 296 16.2 The Language............................................ 296 16.3 JS Objects.............................................. 298 16.4 Creating a JS Console........................................ 299 17 Qt and C++ 305 17.1 A Boilerplate Application...................................... 306 17.2 The QObject............................................. 309 17.3 Build Systems............................................ 311 17.4 Common Qt Classes......................................... 314 17.5 Models in C++............................................ 319 18 Extending QML with C++ 329 18.1 Understanding the QML Run-time.................................. 329 18.2 Plugin Content............................................ 331 18.3 Creating the plugin.......................................... 332 18.4 FileIO Implementation........................................ 333 18.5 Using FileIO............................................. 334 18.6 Summary............................................... 340 19 Felgo Plugins and QML Hot Reloading 343 19.1 Tooling................................................ 343 19.2 Felgo Plugins............................................. 349 19.3 Monetization, Ads and In-App Purchases.............................. 351 19.4 Notifications............................................. 354 19.5 Analytics and Crash Reporting.................................... 357 19.6 Firebase: Authentication, Databases, and Storage.......................... 358 19.7 Cloud Storage, Augmented Reality, and More............................ 361 19.8 Felgo & WebAssembly........................................ 361 19.9 Summary............................................... 361 20 Qt for Python 363 20.1 Introduction............................................. 363 20.2 Installing............................................... 363 20.3 Building an Application....................................... 364 20.4 Limitations.............................................. 375 20.5 Summary............................................... 376 21 Offline Books 377 22 Source Code Examples 379 22.1 Testing................................................ 379 22.2 Deploying QML Applications.................................... 380 22.3 Drag and Drop............................................ 380 iii Index 381 iv Qt5 Cadaques, Release master Last Build: December 07, 2020 at 10:50 CET Welcome to the online book of Qt5 Cadaques! Why Qt5? Because Qt5 is awesome! Why Cadaques? Because one of the authors had a great holiday in this rocky coastline in the north-east of Spain. The entire collection of chapters covering Qt5 programming, written by Jürgen Bocklage-Ryannel and Johan Thelin, is available here. All book content is licensed under the Creative Commons Attribution Non-Commercial Share Alike 4.0 license and examples are licensed under the BSD license. Personal Note Jürgen Ryannel, the lead author has stopped working in his normal job and is bootstrapping a new company called ApiGear, which is all about API architectures. While the company is slowly forming, Jürgen is available for freelancing, ideally in the area of UI creating using QML or UI Architecture coaching. You can reach him via LinkedIn. / jryannel
Recommended publications
  • Qml Controls from Scratch
    CREATING QML CONTROLS FROM SCRATCH Chris Cortopassi Table of Contents Introduction ......................................................................................... 3 Part 0: Getting Started ......................................................................... 4 Part 1: Button ....................................................................................... 6 Part 2: CheckBox and RadioButton ...................................................... 8 Part 3: Switch ...................................................................................... 10 Part 4: Slider ........................................................................................ 12 Part 5: ScrollBar ................................................................................... 14 Part 6: ProgressBar.............................................................................. 15 Part 7: Spinner ..................................................................................... 16 Part 8: Dialog ....................................................................................... 17 Part 9: PageDots .................................................................................. 19 Part 10: Tabs ....................................................................................... 21 Part 11: Table ...................................................................................... 23 Part 12: TimePicker ............................................................................. 25 Part 13: DatePicker .............................................................................
    [Show full text]
  • Qt5 Cadaques Release 2017-12
    Qt5 Cadaques Release 2017-12 JRyannel,JThelin Januar 26, 2018 at 22:39 CET Inhaltsverzeichnis 1 Meet Qt 5 3 1.1 Preface................................................3 1.2 Qt 5 Introduction...........................................4 1.3 Qt Building Blocks..........................................8 1.4 Qt Project............................................... 10 2 Get Started 11 2.1 Installing Qt 5 SDK......................................... 11 2.2 Hello World............................................. 11 2.3 Application Types.......................................... 13 2.4 Summary............................................... 21 3 Qt Creator IDE 23 3.1 The User Interface.......................................... 23 3.2 Registering your Qt Kit....................................... 24 3.3 Managing Projects.......................................... 24 3.4 Using the Editor........................................... 25 3.5 Locator................................................ 25 3.6 Debugging.............................................. 26 3.7 Shortcuts............................................... 26 4 Quick Starter 27 4.1 QML Syntax............................................. 27 4.2 Basic Elements............................................ 32 4.3 Components............................................. 36 4.4 Simple Transformations....................................... 39 4.5 Positioning Elements......................................... 42 4.6 Layout Items............................................. 46 4.7 Input Elements...........................................
    [Show full text]
  • Qt Framework
    About Qt Qt is a framework to develop cross-platform applications. Currently, the supported platforms are Windows, Linux, macOS, Android, iOS, Embedded Linux and some others. Genarally, it means that the programmer may develop the code on one platform but compile, link and run it on another platform. But it also means that Qt needs help: to develop software it must cooperate with development tools on specific platforms, for example in case of Windows with Visual Studio. Qt is well-known for its tools for developing graphical user interfaces (GUI) , but it also provides powerful tools for threads, networking and communication (Bluetooth, serial port, web), 3D graphics, multimedia, SQL databases, etc. Qt has its own Integrated Development Environment (IDE): QtCreator. History: 1991: version 1.0 as cross-platform GUI programming toolkit was developed and implemented by TrollTech (Norway). 2005: version 4.0 was a big step ahead but the compatibility with older versions was lost. 2008: TrollTech was sold to Nokia. 2012: Nokia Qt division was sold to Digia (Finland). 2014: Digia transferred the Qt business to Qt Company. The latest Long Term Support (LTS) version is 5.12. Official website: https://www.qt.io/ Installation The link is https://www.qt.io/download. Select the non-commercial and open source version. It may be possible that you must register yourself creating a new passworded account. Select the latest stable release and the C/C++ development system(s) you are going to use. Tip: the Qt installer proposes to store the stuff in folder C:\Qt. To avoid later complications, agree.
    [Show full text]
  • User Interface Programming Qt
    User Interface Programming Qt Jozef Mlích Department of Computer Graphics and Multimedia Faculty of Information Technology, Brno University of Technology Božetěchova 2, 612 66 Brno, Czech Republic http://www.fit.vutbr.cz/~imlich [email protected] http://www.fit.vutbr.cz/~imlich/ 10.10.2014Qt | 1 / 28 http://www.fit.vutbr.cz/~imlich/ Qt | 2 / 28 Agenda Motivation, Features, History ? (1991-NOW) Architecture of Qt – qmake, other tools – QObject (Meta object model, Events, Signals and slots, Properties, Memory management) – Layouts QML – MVC Advanced topics – C++ and QML – Shaders http://www.fit.vutbr.cz/~imlich/ Qt | 3 / 28 Who is using Qt? Skype for Linux Team Speak Google Earth Autodesk Maya Guitar Pro 6 VLC player GNU Octave OpenSCAD http://www.fit.vutbr.cz/~imlich/ Qt | 4 / 28 Features C++, Python, C#, (Java – Jambi) API for everything (not only GUI) cross-platform – Windows – Mac – Linux – Embedded systems (via “frame buffer”, Qt on Pi) – Mobile devices (Symbian, Maemo, MeeGo, Jolla, Blackberry, Android, iOS) Licence – GPL, LGPL, Commercial http://www.fit.vutbr.cz/~imlich/ Qt | 5 / 28 Architecture http://www.fit.vutbr.cz/~imlich/ Qt | 6 / 28 Compilation and tools qmake, moc, uic cmake, automoc Qt Creator, Qt Linguist, Qt Designer, qmlviewer/qmlscene http://www.fit.vutbr.cz/~imlich/ Qt | 7 / 28 Meta object compiler Qt extends C++ - macro language, introspection, etc. – foreach (int value, intList) { ... } // (i.e. Q_FOREACH) – QObject *o = new QPushButton; o->metaObject()->className(); //returns ”QPushButton”//
    [Show full text]
  • Sailfish OS Interview Questions and Answers Guide
    Sailfish OS Interview Questions And Answers Guide. Global Guideline. https://www.globalguideline.com/ Sailfish OS Interview Questions And Answers Global Guideline . COM Sailfish OS Job Interview Preparation Guide. Question # 1 Tell us what you know about Sailfish OS? Answer:- Sailfish is a Linux-based mobile operating system developed by Jolla in cooperation with the Mer project and supported by the Sailfish Alliance. It is to be used in upcoming smartphones by Jolla and other licencees. Although it is primarily targeted at mobile phones, it is also intended to support other categories of devices. Read More Answers. Question # 2 Explain Sailfish OS Components? Answer:- Jolla has revealed its plans to use the following technologies in Sailfish OS: The Mer software distribution core A custom built user interface HTML5 QML and Qt Read More Answers. Question # 3 Do you know about Sailfish OS software availability? Answer:- Sailfish will be able to run most applications that were originally developed for MeeGo and Android, in addition to native Sailfish applications. This will give it a large catalogue of available apps on launch. Considering upon Jolla's declarations that Sailfish OS is be able to use software from following platforms Sailfish (natively created + ported like from Qt, Symbian, MeeGo - developers have reported that porting a Qt written software with Sailfish SDK takes a few hours only) Android applications are directly running in Sailfish OS. They are compatible as they are in third-party Android stores, with no needed modification (in most cases). MeeGo (because of backward compatibility thanks to MeeGo code legacy included in the Mer core) Unix and Linux (as Sailfish is Linux then using such a software is possible, especially RPM packages, either in terminal/console mode or with limitations implying from using Sailfish UI, if not ported and adjusted) HTML5 Read More Answers.
    [Show full text]
  • Privacy Concerns in Android Advertising Libraries
    RICE UNIVERSITY Privacy Concerns in Android Advertising Libraries by Theodore Book A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree Master of Science Approved, Thesis Committee: Dan S. Wallach, Chair Professor of Computer Science T. S. Eugene Ng Professor of Computer Science Lin Zhong Associate Professor of Electrical and Computer Engineering and Computer Science Houston, Texas November, 2013 ABSTRACT Privacy Concerns in Android Advertising Libraries by Theodore Book This work investigates privacy characteristics of Android advertising libraries. Taking a sample of 114,000 apps, we extract and classify their ad libraries. We then seek to understand how they make use of sensitive user data. First, we study the use of permission-protected Android API calls that provide access to user data. Here, we measure change over time by distinguishing unique versions of each library, dating them, and calculating their permission usage. We find that the use of most permis- sions has increased over the last several years, and that more libraries are able to use permissions that pose particular risks to user privacy and security. Next, we shift to the application side and consider information passed directly from the application to the ad library. We do this by reconstructing the APIs for our libraries, and examining how those APIs are used in our sample of Android applications. We find that many applications pass personal information directly to their ad libraries, without any need for the library to query the operating system directly. This behavior is most com- mon in more popular applications, suggesting that the promise of advertising dollars encourages application developers to violate users' privacy.
    [Show full text]
  • Dissecting Mobile Offerwall Advertisements: an Explorative Study
    2020 IEEE 20th International Conference on Software Quality, Reliability and Security (QRS) Dissecting Mobile Offerwall Advertisements: An Explorative Study 1 1 1 1 2 1∗ 3 1 Guosheng Xu , Yangyu Hu , Qian Guo , Ren He ,LiLi , Guoai Xu , Zhihui Han , and Haoyu Wang 1 Beijing University of Posts and Telecommunications, Beijing, China 2Monash University, Australia 3 CNCERT, Beijing, China Abstract—Mobile advertising has become the most popular monetizing way in the Android app ecosystem. Offerwall, as a new form of mobile ads, has been widely adopted by apps, and a number of ad networks have provided such services. Although new to the ecosystem, offerwall ads have been criticized for being aggressive, and the contents disseminated are prone to security issues. However, to date, our community has not proposed any studies to dissect such issues related to offerwall ads. To this end, we present the first work to fill this gap. Specifically, we first develop a robust approach to identify apps that have embedded with offerwall ads. Then, we apply the tool to 10K apps and experimentally discover 312 offerwall apps. We go one step further to characterize them from several aspects, including security issues. Our observation reveals that offerwall ads could indeed be manipulated by hackers to fulfill malicious purposes. Index Terms—Offerwall, Mobile Advertising, Android, Pay-per Install, Malware I. INTRODUCTION Mobile apps have seen widespread adoption in recent years. The number of apps in Google Play has exceeded 2.7 million 濄濕濗濟濕濛濙濍澳濣濦濛澢濫濣濣濘濦濣濝濘澢濕濠濕濦濡濡濬 濃濚濚濙濦濫濕濠濠 澵濘澔濇濘濟濍澳澵濘濫濣 mark as of August 2019 [1]. A recent study [2] suggested that the app monetization scheme evolves during the evolution Fig.
    [Show full text]
  • Does This App Really Need My Location? Context-Aware Privacy Management for Smartphones 42
    Does this App Really Need My Location? Context-Aware Privacy Management for Smartphones 42 SAKSHAM CHITKARA, Carnegie Mellon University, USA NISHAD GOTHOSKAR, Carnegie Mellon University, USA SUHAS HARISH, Carnegie Mellon University, USA JASON I. HONG, Carnegie Mellon University, USA YUVRAJ AGARWAL, Carnegie Mellon University, USA The enormous popularity of smartphones, their rich sensing capabilities, and the data they have about their users have lead to millions of apps being developed and used. However, these capabilities have also led to numerous privacy concerns. Platform manufacturers, as well as researchers, have proposed numerous ways of mitigating these concerns, primarily by providing fine-grained visibility and privacy controls to the user on a per-app basis. In this paper, we show that this per-app permission approach is suboptimal for many apps, primarily because most data accesses occur due to a small set of popular third-party libraries which are common across multiple apps. To address this problem, we present the design and implementation of ProtectMyPrivacy (PmP) for Android, which can detect critical contextual information at runtime when privacy-sensitive data accesses occur. In particular, PmP infers the purpose of the data access, i.e. whether the data access is by a third-party library or by the app itself for its functionality. Based on crowdsourced data, we show that there are in fact a set of 30 libraries which are responsible for more than half of private data accesses. Controlling sensitive data accessed by these libraries can therefore be an effective mechanism for managing their privacy. We deployed our PmP app to 1,321 real users, showingthat the number of privacy decisions that users have to make are significantly reduced.
    [Show full text]
  • Abstract Window Toolkit Overview
    In this chapter: • Components • Peers 1 • Layouts • Containers • And the Rest • Summary Abstract Window Toolkit Overview For years, programmers have had to go through the hassles of porting software from BSD-based UNIX to System V Release 4–based UNIX, from OpenWindows to Motif, from PC to UNIX to Macintosh (or some combination thereof), and between various other alternatives, too numerous to mention. Getting an applica- tion to work was only part of the problem; you also had to port it to all the plat- forms you supported, which often took more time than the development effort itself. In the UNIX world, standards like POSIX and X made it easier to move appli- cations between different UNIX platforms. But they only solved part of the prob- lem and didn’t provide any help with the PC world. Portability became even more important as the Internet grew. The goal was clear: wouldn’t it be great if you could just move applications between different operating environments without worr yingabout the software breaking because of a different operating system, win- dowing environment, or internal data representation? In the spring of 1995, Sun Microsystems announced Java, which claimed to solve this dilemma. What started out as a dancing penguin (or Star Trek communicator) named Duke on remote controls for interactive television has become a new paradigm for programming on the Internet. With Java, you can create a program on one platform and deliver the compilation output (byte-codes/class files) to ever yother supported environment without recompiling or worrying about the local windowing environment, word size, or byte order.
    [Show full text]
  • Drawing in GTK+
    CSci493.70 Graphical User Interface Programming Prof. Stewart Weiss Drawing in GTK+ Drawing in GTK+ Background In order to understand how to draw in GTK, you rst have to understand something about how GTK draws widgets, because how GTK draws widgets has an important role in how you design your drawing application. An understanding of how GTK draws widgets is also required if you ever plan to build your own custom widgets. Windows and Clipping Most windowing systems are designed around the idea that an application's visual display lies within a rectangular region on the screen called its window. The windowing system, e.g. Gnome or KDE or Explorer, does not automatically save the graphical content of an application's windows; instead it asks the application itself to repaint 1 its windows whenever it is needed. For example, if a window that is stacked below other windows gets raised to the top, then a client program has to repaint the area that was previously obscured. When the windowing system asks a client program to redraw part of a window, it sends an exposure event to the program that contains that window. An exposure event is simply an event sent from the underlying windowing system to a widget to notify it that it must redraw itself. In this context, a "window" means "a rectangular region with automatic clipping", not a top-level application window. Clipping is the act of removing portions of a window that do not need to be redrawn, or looked at the other way, it is determining which are the only regions of a window that must be redrawn.
    [Show full text]
  • Creating Meego Products in a Different Way and Faster - How to Change the Device Creation
    Creating MeeGo products in a different way and faster - How to change the device creation Pasi Nieminen CEO [email protected] +358 40 737 3907 www.nomovok.com 1 The Questions That I Try Answer Today How to make product faster & better in MeeGo world How/why to change the UX creation - QML? MeeGo for ARM, where is it now? Where to find companies to work on MeeGo? 2 About Us We create products build on Open Source technologies #1 MeeGo company Pioneer in Embedded Open Source Pioneer in commercial utilization of Open Source in embedded devices. Since 2001, more than 400 OSS deployment project delivered Employs 110 OSS experts globally 400 more in ZCOCO.net for deep Linux expertize Locations 3 Currently serving businesses in Japan, Germany, France, US, Finland and Korea. Insider's View to MeeGo - Where Are We Now? 4 Current MeeGo Deployment Status Currently FULL build & integration pipeline working Currently MeeGo-dev + QT4.7 + NOMOVOK Steel Rat UX running on STE U8500 / Freescale i.mx51 / Renesas AP4 (All ARMv7 optimized) / IA See our demo @ demo area, and NOMOVOK staff 5 Forget C++ & Native QT apps - Go for QML 6 MeeGo Apps – Faster QT4.7 enables QML apps Declarative UI XML + JS 3x faster app creation to QT native apps Performance almost equal to native QT apps, in future much faster (declarative GUI => GPU) 7 QML – hello world import Qt 4.7 Rectangle { id: page width: 500; height: 200 color: "lightgray" Text { id: helloText8 text: "Hello world!" y: 30 anchors.horizontalCenter: page.horizontalCenter font.pointSize:
    [Show full text]
  • Our Journey from Java to Pyqt and Web for Cern Accelerator Control Guis I
    17th Int. Conf. on Acc. and Large Exp. Physics Control Systems ICALEPCS2019, New York, NY, USA JACoW Publishing ISBN: 978-3-95450-209-7 ISSN: 2226-0358 doi:10.18429/JACoW-ICALEPCS2019-TUCPR03 OUR JOURNEY FROM JAVA TO PYQT AND WEB FOR CERN ACCELERATOR CONTROL GUIS I. Sinkarenko, S. Zanzottera, V. Baggiolini, BE-CO-APS, CERN, Geneva, Switzerland Abstract technology choices for GUI, even at the cost of not using Java – our core technology – for GUIs anymore. For more than 15 years, operational GUIs for accelerator controls and some lab applications for equipment experts have been developed in Java, first with Swing and more CRITERIA FOR SELECTING A NEW GUI recently with JavaFX. In March 2018, Oracle announced that Java GUIs were not part of their strategy anymore [1]. TECHNOLOGY They will not ship JavaFX after Java 8 and there are hints In our evaluation of GUI technologies, we considered that they would like to get rid of Swing as well. the following criteria: This was a wakeup call for us. We took the opportunity • Technical match: suitability for Desktop GUI to reconsider all technical options for developing development and good integration with the existing operational GUIs. Our options ranged from sticking with controls environment (Linux, Java, C/C++) and the JavaFX, over using the Qt framework (either using PyQt APIs to the control system; or developing our own Java Bindings to Qt), to using Web • Popularity among our current and future developers: technology both in a browser and in native desktop little (additional) learning effort, attractiveness for new applications.
    [Show full text]