Lab 12: GUI programming with Qt

Similar documents
INSTRUCTIONS: GOOD LUCK! [TURN OVER]

Praktische Aspekte der Informatik

C++ GUI Programming with Qt 3

Qt Essentials - Fundamentals of Qt Module

Qt-Based Implementation of Low Level ROOT Graphical Layer

Qt Essentials - Fundamentals of Qt Module

Object-Oriented Programming

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

Python GUIs. $ conda install pyqt

NHERI SIMCENTER PROGRAMMING BOOTCAMP JULY 30 THROUGH AUGUST 3, 2018, AT UC BERKELEY S RICHMOND FIELD STATION. GUI Development

Qt Essentials - Objects Module

Designing Interactive Systems II

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

QObject. An important class to become familiar with is the one from which all Qt Widgets are derived: QObject.

COS2614. Tutorial letter 203/1/2018. Programming: Contemporary Concepts. Semester 1. School of Computing. Discussion of Solutions to Assignment 3

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

OpenGL Introduction Computer Graphics and Visualization

C++ GUI Programming with Qt 3. Rozália Szabó Nacsa Eötvös Loránd University, Budapest

Introduction to CGAL. Constantinos Tsirogiannis. TU/Eindhoven

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

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

Tuesday, 9 March Introduction to Qt

QT/KDE Research Paper CS B 27 February 2002

Lab 1 The Basics of Qt

Friday, 4 January 13. Introduction to Qt

Qt Essentials - Application Creation Module

CopperSpice: A Pure C++ GUI Library. Barbara Geller & Ansel Sermersheim CPPCon - September 2015

Luis Ibáñez William Schroeder Insight Software Consortium. ITK and Graphical User Interface

Qt Introduction. Topics. C++ Build Process. Ch & Ch 3. 1) What's Qt? 2) How can we make a Qt console program? 3) How can we use dialogs?

CSC111 Computer Science II

Integrating QML with C++

Exercises Lecture 3 Layouts and widgets

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

Unix Philosophy, Text Editors, IDEs

Selected PyQt Widgets

LECTURE 17. GUI Programming

Tutorial 1 C Tutorial: Pointers, Strings, Exec

Exercises Lecture 2 The Qt Object Model and Signal Slot Mechanism

OO for GUI Design (contd.) Questions:

OpenGL and Qt Creator: a Gentle Introduction

Contents ROOT/Qt Integration Interfaces

LECTURE 18 GUI Programming Part 2

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

Object-Oriented Programming, Iouliia Skliarova

Mar :51 gltexobj.cpp

Reviewing gcc, make, gdb, and Linux Editors 1

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview

QROSE Manual. Jose Gabriel de Figueiredo Coutinho

Recitation 2/18/2012

+ C++11. Qt5 with a touch of C++11. Matthew Eshleman covemountainsoftware.com

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

Graphical User Interfaces

PRINCIPLES OF OPERATING SYSTEMS

CopperSpice and the Next Generation of Signals. Barbara Geller & Ansel Sermersheim CppNow - May 2016

Common Misunderstandings from Exam 1 Material

CSE 333 Midterm Exam 7/29/13

ECE 449 OOP and Computer Simulation Lecture 11 Design Patterns

Qt Essentials - Widgets Module

Creating a Shell or Command Interperter Program CSCI411 Lab

Qt Essentials - Basic Types Module

Chapter 11 Introduction to Programming in C

Image Processing with Qt BY KLAUDIO VITO

switch case Logic Syntax Basics Functionality Rules Nested switch switch case Comp Sci 1570 Introduction to C++

Programming the DMCC in C

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C

Marble Developers Guide

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3

Using the GeoX Framework

CS354 gdb Tutorial Written by Chris Feilbach

CS 220: Introduction to Parallel Computing. Input/Output. Lecture 7

Higher-Performance R Programming with C++ Extensions

Getting to know you. Anatomy of a Process. Processes. Of Programs and Processes

Prof. Tiago G. S. Carneiro DECOM - UFOP. Threads em Qt. Prof. Tiago Garcia de Senna Carneiro

Chapter 11 Introduction to Programming in C

Asynchronous Database Access with Qt 4.x

Qt in Education. The Qt object model and the signal slot concept

Lab 1: First Steps in C++ - Eclipse

Lecture 15a Persistent Memory & Shared Pointers

Qt Quick From bottom to top

G52CPP C++ Programming Lecture 3. Dr Jason Atkin

Incoming Exam. CS 201 Introduction to Pointers. What is a Pointer? Pointers and Addresses. High Speed Memory (RAM) Size of Variable Types.

C++ Important Questions with Answers

Qtopia Core 4.2 Whitepaper

Computer Science 322 Operating Systems Mount Holyoke College Spring Topic Notes: C and Unix Overview

Slide Set 9. for ENCM 335 in Fall Steve Norman, PhD, PEng

Ch. 11: References & the Copy-Constructor. - continued -

This whitepaper describes the Qt C++ framework. Qt supports the development of crossplatform GUI applications with its write once, compile anywhere

CS 237 Meeting 19 10/24/12

CSE 333 Lecture 6 - data structures

Chapter 11 Introduction to Programming in C

Creating Dynamic UIs with Qt Declarative UI

Midterm Exam 2 Solutions C Programming Dr. Beeson, Spring 2009

Test-Driven Development with Qt and KDE

Call-by-Type Functions in C++ Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #5

MEIN 50010: Python Introduction

3L Diamond. Multiprocessor DSP RTOS

CSE au Midterm Exam Nov. 2, 2018 Sample Solution

Program Organization and Comments

Transcription:

Lab 12: GUI programming with Comp Sci 1585 Data Structures Lab: Tools for Computer Scientists

Outline 1

Outline 1

(Pronounced cute ) https://www.qt.io/what-is-qt/ https://showroom.qt.io/ https://en.wikipedia.org/wiki/_(software) is used for developing multi-platform s and graphical user interfaces (GUIs) So far, we ve only created command-line s GUIs can be nice at times, though : cross-platform framework (works on Windows, Mac OS X, Linux, etc) Little to no underlying changes needed to port from one system to another Native OS capabilities and speed

Making GUIs with 4 Besides making clickable programs, learning to program GUIs will give you several other skills with C++ Event-based programming Working with a (very) large library Managing memory in more complicated programs

Getting Started #include <Gui> int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel hello("hello World!"); hello.resize(250, 150); hello.setwindowtitle(" example"); hello.show(); } return app.exec();

Outline 1

Building Applications has its own preprocessor, the Meta Object Compiler (aka moc ) qmake-qt4 manages projects and generates makefiles automatically $ qmake-qt4 -project will make a project file (ends in.pro) that configures the makefile $ qmake-qt4 makes a makefile So, to build a project: $ qmake-qt4 -project; qmake-qt4; make

Overview There is one, and only one, QApplication qapp is a global pointer to the QApplication Everything clickable is called a widget Widgets can hold other widgets A widget with no parent becomes a window

Outline 1

A Notepad #include<qapplication> #include<qtextedit> int main(int argc, char** argv) { QApplication app(argc,argv); QTextEdit te; te.setwindowtitle("not Vim"); te.show(); return app.exec(); }

Outline 1

Composite Objects Widgets can be added to another widget with the addwidget() function You can use a Layout to specify how the widgets are organized Memory Management: addwidget() takes a pointer and is responsible for cleaning up all its children

Layout Example #include<gui> int main(int argc, char** argv) { QApplication app(argc,argv); QTextEdit* te = new QTextEdit; QPushButton* quit = new QPushButton("&Quit"); QVBoxLayout* layout = new QVBoxLayout; layout->addwidget(quit); layout->addwidget(te); QWidget window; window.setlayout(layout); window.show(); return app.exec(); }

Outline 1

Making Buttons Do Things is event-driven: QApplication monitors what the user does and sends events to widgets when something happens Signal: An event caused by a widget: button click, key press, etc. Slot: An action taken when a signal is sent Signals are connected to slots by using the connect(...) function e.g. connect(source-object, SIGNAL(signal name()), destination-object, SLOT(slot name())) connects signals to slots

Actually Quitting #include<gui> int main(int argc, char** argv) { QApplication app(argc,argv); QTextEdit* te = new QTextEdit; QPushButton* quit = new QPushButton("&Quit"); QObject::connect(quit, SIGNAL(clicked()), qapp, SLOT(quit())); QVBoxLayout* layout = new QVBoxLayout; layout->addwidget(quit); layout->addwidget(te); QWidget window; window.setlayout(layout); window.show(); return app.exec(); }

Writing your own slot In order to make your own slots, you need to make a custom QWidget class In addition to public and private functions and members, QObjects have public and private slots A slot is just a function that gets called whenever a signal connected to it is sent Example: ask-quit

Outline 1

Toolbars QMainWindow is a class for making standard s with menus and setcentralwidget() sets the widget that fills the window menubar() returns a pointer to the menubar, which you can use to add new menus addtoolbar() creates a new toolbar To avoid repeating a lot of code, you can add a QAction to both a menu and a toolbar Then you can connect that one action to various slots Example: menus

Outline 1

Sending Data Between Signals and Slots So far, we ve used predefined signals e.g. QPushButton::clicked() e.g. QAction::triggered() connect() dictates which signals trigger which slots e.g. openaction::triggered() executes Notepad::open() Custom slots were responsible for gathering data Notepad::open() promped user to select file Grabbed filename Tried to open; complained if it couldn t Loaded file contents into QTextEdit instance Another approach: have signals send data to slots Solution: declare your own signals!

Sending Data Between Signals and Slots You can declare your own signals in the signals: section of your header files Then, custom slots can emit these signals: emit signal-name(); You don t actually implement signals, just declare, emit, and connect them Signals can carry data, just add parameters Connect that signal to a slot that takes the same arguments The slot will be called with the data you use when you emit the signal Example: title

Outline 1

-creator makes an IDE for developing s: https://en.wikipedia.org/wiki/_creator