Object-Oriented Programming

Similar documents
Exercises Lecture 3 Layouts and widgets

Qt Essentials - Fundamentals of Qt Module

C++ GUI Programming with Qt 3

Qt Essentials - Fundamentals of Qt Module

Python GUIs. $ conda install pyqt

Selected PyQt Widgets

Qt Essentials - Widgets Module

JavaFX. Getting Started with JavaFX Scene Builder Release 1.1 E

Lab 12: GUI programming with Qt

Tutorial 1: Getting Started with Excel

Using Adobe Contribute 4 A guide for new website authors

Qt + Maemo development

GUI in C++ PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill. Faculty of Informatics, Masaryk University.

Rich Text Editor Quick Reference

ECE 462 Object-Oriented Programming using C++ and Java. Graphical User Interface

2. The quiz screen showing the question, text field (QLineEdit in QT) for the answer and the Next Question button

CS 4300 Computer Graphics

Microsoft Office Access Learn how to use the Query window in Design view. Tutorial 3b Querying a Database

WEEK NO. 12 MICROSOFT EXCEL 2007

Interface Builders and Interface Description Languages

Report Designer Report Types Table Report Multi-Column Report Label Report Parameterized Report Cross-Tab Report Drill-Down Report Chart with Static

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,

About 1. Chapter 1: Getting started with pyqt5 2. Remarks 2. Examples 2. Installation or Setup 2. Hello World Example 6. Adding an application icon 8

SPARK. User Manual Ver ITLAQ Technologies

NETZONE CMS User Guide Copyright Tomahawk

How to create a prototype

LAYOUT. Chapter 3 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon

Graphical User Interfaces

Working with Tables in Microsoft Word

New Perspectives on Microsoft Excel Module 1: Getting Started with Excel

Mi c r o s o f t Wo r d Qu i c k Re f e r e n c e Ca r d

GUI Design for Android Applications

Word Creating & Using Tables. IT Training & Development (818) Information Technology

Free Form Text Page Wizard: Version 9.3

What is Widget Layout? COSC 3461 User Interfaces. Hierarchical Widget Layout. Resizing a Window. Module 5 Laying Out Components

SharePoint List Booster Features

Creating Dynamic UIs with Qt Declarative UI

Designing Interactive Systems II

1. What are the key components of Android Architecture? 2. What are the advantages of having an emulator within the Android environment?

MockupScreens - User Guide

Review. Designing Interactive Systems II. Introduction. Web 2.0 in keywords GWT Cappuccino HTML5. Cross platform GUI Toolkit

OpenGL and Qt Creator: a Gentle Introduction

Microsoft PowerPoint 2016 Basics Unit 9 Final Review - Student Notes Directions: Fill in the blanks.

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu

Tcl/Tk lecture. What is the Wish Interpreter? CIS 410/510 User Interface Programming

Creating a Spreadsheet by Using Excel

Overview of the Adobe Dreamweaver CS5 workspace

LECTURE 18 GUI Programming Part 2

Microsoft Excel is a spreadsheet tool capable of performing calculations, analyzing data and integrating information from different programs.

P3e REPORT WRITER CREATING A BLANK REPORT

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu

GUI Components: Part 1

Laying Out Components. What is Widget Layout?

How to use the ruler, grid, guides, and the Align panel

COLLEGE OF ENGINEERING, NASHIK-4

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu

Nauticom NetEditor: A How-to Guide

A PRACTICAL GUIDE TO USING WIX TO BUILD A WEBSITE

Lesson 4 - Creating a Text Document Using WordPad

Oh my. Maya is Qt! Kristine Middlemiss, Autodesk Developer Consultant, Autodesk Developer Network

USER GUIDE MADCAP FLARE Tables

The MVC Design Pattern

Excel Main Screen. Fundamental Concepts. General Keyboard Shortcuts Open a workbook Create New Save Preview and Print Close a Workbook

Microsoft Word 2007 on Windows

How to Edit Your Website

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

Document Revision No.: 1 Revised: 03/12/09 RIT KGCOE MSD Program. P09027 Upper Extremity Motion Capture System. Software Manual

How to lay out a web page with CSS

GUI Basics and Windowing Systems

Business Intelligence and Reporting Tools

Layout Manager - Toolbar Reference Guide

Microsoft Excel 2013: Excel Basics June 2014

Mobile Programming Lecture 1. Getting Started

Dive Into Visual C# 2008 Express

Getting Started Guide

Chapter 1: PageMaker Commands and InDesign Equivalents

Dell Canvas Layout. Version 1.0 User s Guide

GUI Basics and Windowing Systems. Using X Windows as a case study

Contents SECTION-I : LINUX

Layout. Dynamic layout, Swing and general layout strategies

Chapter 2 First Java Programs

Ms excel. The Microsoft Office Button. The Quick Access Toolbar

Formatting, Saving and Printing in Word 2013

Free Microsoft Office 2010 training from MedCerts. Course Outline

COMPUTERIZED OFFICE SUPPORT PROGRAM

Qt Quick From bottom to top

Creating Reports in Access 2007 Table of Contents GUIDE TO DESIGNING REPORTS... 3 DECIDE HOW TO LAY OUT YOUR REPORT... 3 MAKE A SKETCH OF YOUR

Label Design Program Label Artist-II Manual Rev. 1.01

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

Microsoft Word 2011 Tutorial

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial

How to set up a local root folder and site structure

How to Edit Your Website

Management Reports Centre. User Guide. Emmanuel Amekuedi

ADJUST TABLE CELLS-ADJUST COLUMN AND ROW WIDTHS

Aware IM Version 8.2 Aware IM for Mobile Devices

Index. borders adding to cells, 174 draw border line tool, using to add, 175

ECDL Full Course Content

Transcription:

iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 33

Overview 1 2 3 4 5 6 2 / 33

I Qt is a cross-platform application and UI framework in C++. Using Qt, one can write GUI applications once and deploy them across desktop, mobile and embedded operating systems without rewriting the source code. Qt is supported on a variety of 32-bit and 64-bit platforms (Desktop, embedded, mobile): Windows (MinGW, MSVS) Linux (gcc) Apple Mac OS Mobile / Embedded (Windows CE, Windows Mobile, Symbian, Embedded Linux) 3 / 33

II Language bindings are available in C#, Java, Python(PyQt), Ada, Pascal, Perl, PHP(PHP-Qt), Ruby(RubyQt). Qt is available under GPL v3, LGPL v2 and commercial license. Real applications developed using Qt: Google Earth, KDE (desktop environment for Unix-like OS), Adobe Photoshop Album. Qt documentation: http://doc.qt.io/qt-5/. 4 / 33

Download and install Qt Please see the tutorial on how to install Qt Library at http://www.cs.ubbcluj.ro/~iuliana/oop/ - Tutorials Qt can be used with Microsoft Visual Studio as well as with Eclipse (provided there is a C++ compiler installed). There is also an IDE which is part of the SDK for the Qt GUI Application development framework - QtCreator. This also needs a C++ compiler. 5 / 33

Qt Hello World - Project Wizard I Create a new Qt application, as described in the tutorial mentioned on the previous slide. Edit the file main.cpp: add a new QLabel and display it, as follows: #i n c l u d e <QtWidgets / Q A p p l i c a t i o n > #i n c l u d e <QtWidgets / QLabel> int main ( int argc, char a r g v [ ] ) { Q A p p l i c a t i o n a ( argc, a r g v ) ; QLabel l a b e l ( "Hello world!" ) ; l a b e l. show ( ) ; return a. e xec ( ) ; } 6 / 33

Qt Hello World - Project Wizard II By executing the application, you should get the following result: 7 / 33

I The class manages the GUI application s control flow and main settings. contains the main event loop, where all events from the window system and other sources are processed and dispatched. For any GUI application using Qt, there is exactly one object (no matter how many windows the application has at any given time). This object is accessible using the function instance(). 8 / 33

II Responsibility: initializes the application with the user s desktop settings; takes care of the event loop: performs event handling, it receives events from the underlying window system and dispatches them to the relevant widgets; knows about the application s windows; defines the application s look and feel. 9 / 33

III For non-gui Qt applications, use QCoreApplication instead. The exec() method of the makes the application enter its event loop. When a Qt application is running, the event loop waits for user input, then events are generated and sent to the widgets of the application. The loop is terminated when any of the functions exit() or quit() is called. 10 / 33

I Widgets are the basic building blocks for graphical user interface (GUI) applications built with Qt. E.g.: buttons, labels, textboxes, etc. A GUI component (widget) can be placed on the user interface window or can be displayed as independent window. A widget that is not embedded in a parent widget is called a window. Windows provide the screen space upon which the user interface is built. 11 / 33

II Windows visually separate applications from each other and usually provide a window decoration (show a title bar, allows the user to resize, position, etc). The Widgets module in Qt uses inheritance. All widgets inherit from QWidget, which is derived from QObject. 12 / 33

III Figure source: https://wiki.qt.io/qt_for_beginners 13 / 33

IV Widgets use the parenting system: Any object that inherits from QObject can have a parent and children. When an object is destroyed, all of its children are destroyed as well. All QObjects have methods that allow searching the object s children. Child widgets in a QWidget automatically appear inside the parent widget. 14 / 33

Widget example - label QLabel QLabel is used for displaying text or an image. No user interaction functionality is provided. A QLabel is often used as a label for an interactive widget. For this use QLabel provides a useful mechanism for adding an mnemonic that will set the keyboard focus to the other widget (called the QLabel s buddy ). Is defined in the header <QLabel>. QLabel l a b e l ( "Hello :)" ) ; l a b e l. show ( ) ; 15 / 33

Widget example - textbox QLineEdit QLineEdit widget is a one-line text editor. A line edit allows the user to enter and edit a single line of plain text with a useful collection of editing functions, including undo and redo, cut and paste, and drag and drop. A related class is QTextEdit which allows multi-line, rich text editing. Is defined in the header <QLineEdit>. QLineEdit l i n e E d i t ; QLabel l a b e l ( "&Hello :)" ) ; l a b e l. setbuddy (& l i n e E d i t ) ; 16 / 33

Widget example - button QPushButton The QPushButton widget provides a command button. Push (click) a button to command the computer to perform some action. Push buttons display a textual label, and optionally a small icon. A shortcut key can be specified by preceding the preferred character with an ampersand. Is defined in the header <QPushButton>. DEMO Push button (Lecture9 demo widgets - function buttonexample). 17 / 33

Widget example - list QListWidget The QListWidget widget provides an item-based list widget. The widget presents a list of items to the user. QListWidget uses an internal model to manage each item in the list (QListWidgetItem). Is defined in the header <QListWidget>. DEMO List (Lecture9 demo widgets - function listexample). 18 / 33

I The Qt layout system provides a way to automatically arrange child widgets within a widget to ensure that they make good use of the available space. Qt includes a set of layout classes that are used to describe how widgets are laid out in an application s user interface. These layouts automatically position and resize widgets when the amount of space available for them changes, ensuring that they are consistently arranged and that the user interface as a whole remains usable. 19 / 33

II 20 / 33

QHBox Widgets are aligned horizontally. DEMO QHBox (Lecture9 demo widgets - function hbox). 21 / 33

QVBox Widgets are aligned vertically. DEMO QVBox (Lecture9 demo widgets - function vbox). 22 / 33

QForm Widgets are layed out in a two column form. The left column contains labels and the right column contains widgets. DEMO QForm (Lecture9 demo widgets - function form). 23 / 33

QGrid Widgets are layed out in a grid. The space is divided into rows and columns and each widget is put in the specified cell. It is also possible for a widget to occupy multiple cells by spanning the row/column. DEMO QGrid (Lecture9 demo widgets - function grid). 24 / 33

and widgets combinations Multiple widgets can be nested and different layouts can be used to create a GUI. DEMO Multiple layouts (Lecture9 demo widgets - function multiples). 25 / 33

Key benefits of using layout managers I They provide a consistent behavior across different screen sizes and styles. managers handle resize operations. They automatically adapt to different fonts and platforms. If the user changes the systems font settings, the applications forms will respond immediately, resizing themselves if necessary. 26 / 33

Key benefits of using layout managers II They automatically adapt to different languages. If the applications user interface is translated to other languages, the layout classes take into consideration the widgets translated contents to avoid text truncation. If a widget is added to or removed from a layout, the layout will automatically adapt to the new situation (the same thing happens when applying the show() or hide() functions for a widget). 27 / 33

Absolute positioning I An absolute position can be specified for a widget using the function setgeometry(), which builds a rectangle using the given parameters (x and y positions, width and height). Absolute positioning disadvantages If the window is resized, the widgets with absolute positions remain unchanged. Some text may be truncated (large font or change in the labels). The positions and sizes must be calculated manually (errorprone, hard to maintain). 28 / 33

Absolute positioning II DEMO Absolute positioning (Lecture9 demo widgets - functions create- Absolute and createwith). 29 / 33

I is the Qt tool for designing and building GUIs. Windows and dialogs can be designed in a what-you-see-iswhat-you-get manner. Objects can be dragged from the widget box and dropped on the form. Object properties can be modified interactively. 30 / 33

II DEMO Using the can be faster than hand-coding the interface. One can experiment with different designs quickly. A.ui file is created, representing the widget tree of the form in XML format. This file can be used at compile time to generate C++ code that can be compiled. (Lecture9 demo Qt designer). 31 / 33

When should we write code programatically? When the elements in the dialog must change dynamically. When we want to use custom widgets. How? 1 Create a new class, by inheriting from QWidget. 2 Implement the GUI. 3 Show the newly created widget. DEMO Dynamically changing elements (Lecture9 demo Qt designer - ProgramaticallyDesignedWidget class). 32 / 33

1 Instantiate the required Qt widgets. 2 Set properties for these, if necessary. 3 Add the widgets to a layout (the layout manager will take care of the position and size). 4 Connect the widgets using the signal and slot mechanism (will be presented next week). 33 / 33