Qt 5 Application Framework Gnuplot Plotting Library. Δρ. Γ. Χαμόδρακας

Σχετικά έγγραφα
Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 5: Component Adaptation Environment (COPE)

The Simply Typed Lambda Calculus

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ - ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 133: ΑΝΤΙΚΕΙΜΕΝΟΣΤΡΕΦΗΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

VBA ΣΤΟ WORD. 1. Συχνά, όταν ήθελα να δώσω ένα φυλλάδιο εργασίας με ασκήσεις στους μαθητές έκανα το εξής: Version ΗΜΙΤΕΛΗΣ!!!!

2 Composition. Invertible Mappings

TaxiCounter Android App. Περδίκης Ανδρέας ME10069

Partial Trace and Partial Transpose

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

Εισαγωγή στη Βιοπληροφορική

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade

SPEEDO AQUABEAT. Specially Designed for Aquatic Athletes and Active People

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ

Calculating the propagation delay of coaxial cable

Section 9.2 Polar Equations and Graphs

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Δημιουργία Λογαριασμού Διαχείρισης Business Telephony Create a Management Account for Business Telephony

Assalamu `alaikum wr. wb.

Αντικειμενοστραφής Προγραμματισμός I (5 ο εξ) Εργαστήριο #1 ο : Εισαγωγή στο Περιβάλλον Ανάπτυξης (IDE)

derivation of the Laplacian from rectangular to spherical coordinates

Αντικειμενοστραφής Προγραμματισμός I(5 ο εξ) Εργαστήριο #1 ο : Εισαγωγή στο Περιβάλλον Ανάπτυξης (IDE)

Section 8.3 Trigonometric Equations

Instruction Execution Times

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

Αρχές Τεχνολογίας Λογισμικού Εργαστήριο

Συστήματα Διαχείρισης Βάσεων Δεδομένων

How to register an account with the Hellenic Community of Sheffield.

SOAP API. Table of Contents

C.S. 430 Assignment 6, Sample Solutions

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

(C) 2010 Pearson Education, Inc. All rights reserved.

Δίκτυα Επικοινωνιών ΙΙ: OSPF Configuration

Galatia SIL Keyboard Information

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

GREECE BULGARIA 6 th JOINT MONITORING

ΠΑΝΕΠΙΣΤΗΜΙΟ ΘΕΣΣΑΛΙΑΣ ΤΜΗΜΑ ΠΟΛΙΤΙΚΩΝ ΜΗΧΑΝΙΚΩΝ ΤΟΜΕΑΣ ΥΔΡΑΥΛΙΚΗΣ ΚΑΙ ΠΕΡΙΒΑΛΛΟΝΤΙΚΗΣ ΤΕΧΝΙΚΗΣ. Ειδική διάλεξη 2: Εισαγωγή στον κώδικα της εργασίας

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

PARTIAL NOTES for 6.1 Trigonometric Identities

Homework 3 Solutions

Διπλωματική Εργασία του φοιτητή του Τμήματος Ηλεκτρολόγων Μηχανικών και Τεχνολογίας Υπολογιστών της Πολυτεχνικής Σχολής του Πανεπιστημίου Πατρών

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Démographie spatiale/spatial Demography

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

ΕΙΣΑΓΩΓΗ ΣΤΟN ΠΡΟΓΡΑΜΜΑΤΙΣΜΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΑΤΡΩΝ ΠΟΛΥΤΕΧΝΙΚΗ ΣΧΟΛΗ ΤΜΗΜΑ ΜΗΧΑΝΙΚΩΝ Η/Υ ΚΑΙ ΠΛΗΡΟΦΟΡΙΚΗΣ

HY150a Φροντιστήριο 3 24/11/2017

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

Quick Installation Guide

Τμήμα Πολιτικών και Δομικών Έργων

Δυναμική μνήμη με πίνακες και λίστες

Potential Dividers. 46 minutes. 46 marks. Page 1 of 11

Συντακτικές λειτουργίες

«Χρήσεις γης, αξίες γης και κυκλοφοριακές ρυθμίσεις στο Δήμο Χαλκιδέων. Η μεταξύ τους σχέση και εξέλιξη.»

Block Ciphers Modes. Ramki Thurimella

Hancock. Ζωγραφάκης Ιωάννης Εξαρχάκος Νικόλαος. ΕΠΛ 428 Προγραμματισμός Συστημάτων

Right Rear Door. Let's now finish the door hinge saga with the right rear door

Εικονική Αναπαράσταση Νοηµατικής Γλώσσας στο ιαδίκτυο

Section 7.6 Double and Half Angle Formulas

the total number of electrons passing through the lamp.

Finite Field Problems: Solutions

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

Παρουσίαση Delphi. Μέμος-Μπαγκράτσας Ιωάννης 1232 Μαργαρίτης Νικόλαος 1226

[1] P Q. Fig. 3.1

Approximation of distance between locations on earth given by latitude and longitude

Η ιευρυµένη Επιχείρηση Ενότητα Ηλεκτρονικής Μάθησης. «CourseLab» 3ο Φροντιστήριο. Ιωάννα Ταλάντη Υπ. ιδάκτωρ, Τµήµα ιοικητικής Επιστήµης & Τεχνολογίας

Diving in the code of a CMS

Congruence Classes of Invertible Matrices of Order 3 over F 2

ΠΑΝΔΠΙΣΗΜΙΟ ΜΑΚΔΓΟΝΙΑ ΠΡΟΓΡΑΜΜΑ ΜΔΣΑΠΣΤΥΙΑΚΧΝ ΠΟΤΓΧΝ ΣΜΗΜΑΣΟ ΔΦΑΡΜΟΜΔΝΗ ΠΛΗΡΟΦΟΡΙΚΗ

Η ΠΡΟΣΩΠΙΚΗ ΟΡΙΟΘΕΤΗΣΗ ΤΟΥ ΧΩΡΟΥ Η ΠΕΡΙΠΤΩΣΗ ΤΩΝ CHAT ROOMS

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.

Example Sheet 3 Solutions

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

b. Use the parametrization from (a) to compute the area of S a as S a ds. Be sure to substitute for ds!

Εργαστήριο 9. Styling with Javascript

Bizagi Modeler: Συνοπτικός Οδηγός

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 11/3/2006

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Μιχάλης Βαφόπουλος, vafopoulos.org

ΑΝΙΧΝΕΥΣΗ ΓΕΓΟΝΟΤΩΝ ΒΗΜΑΤΙΣΜΟΥ ΜΕ ΧΡΗΣΗ ΕΠΙΤΑΧΥΝΣΙΟΜΕΤΡΩΝ ΔΙΠΛΩΜΑΤΙΚΗ ΕΡΓΑΣΙΑ

Statistical Inference I Locally most powerful tests

ΕΘΝΙΚΗ ΣΧΟΛΗ ΔΗΜΟΣΙΑΣ ΔΙΟΙΚΗΣΗΣ ΙΓ' ΕΚΠΑΙΔΕΥΤΙΚΗ ΣΕΙΡΑ

Fractional Colorings and Zykov Products of graphs

Code Breaker. TEACHER s NOTES

Αναερόβια Φυσική Κατάσταση

(Διαφάνειες Νίκου Βιδάκη)

A browser-based digital signing solution over the web

Εργαστήριο Java. Διδάσκουσα: Εργαστηριακοί Συνεργάτες:

The challenges of non-stable predicates

ΜΕΤΑΠΤΥΧΙΑΚΗ ΔΙΠΛΩΜΑΤΙΚΗ ΕΡΓΑΣΙΑ «ΘΕΜΑ»

Solutions to the Schrodinger equation atomic orbitals. Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz

ST5224: Advanced Statistical Theory II

Οδηγίες χρήσης. Registered. Οδηγίες ένταξης σήματος D-U-N-S Registered στην ιστοσελίδα σας και χρήσης του στην ηλεκτρονική σας επικοινωνία

(1) Describe the process by which mercury atoms become excited in a fluorescent tube (3)

Transcript:

Qt 5 Application Framework Gnuplot Plotting Library Δρ. Γ. Χαμόδρακας

Qt / Gnuplot Qt: a cross platform application framework Main use: C++ application development with Graphical User Interfaces Current version: Qt 5 Gnuplot: a program generating 2 and 3 dimensional plots of functions or data Can be built as a library providing QtGnuplotWidget class Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 2

Qt 5 installation Ubuntu distribution: $sudo apt-get install build-essential mesa-common-dev $sudo apt-get install libglu1-mesa-dev -y $sudo apt-get install libxt-dev qt5-default qtquick1-5-dev qtdeclarative5-dev qtscript5-dev libqt5webkit5-dev qttools5-dev-tools qtcreator $sudo apt-get install ^libqt5svg5 If Ubuntu runs as a VirtualBox Appliance 3d acceleration must be disabled. Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 3

Gnuplot Installation (1) Build Gnuplot as a library $sudo apt-get install automake libtool cvs $cvs -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot login $cvs -z3 -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot co -P gnuplot $cd gnuplot $wget http://sourceforge.net/p/gnuplot/patches/_discuss/thread/47917802/fbe5/attachment/qtlib6.patch $patch -p0 < qtlib6.patch $libtoolize $./prepare $./configure --with-qt=lib $export QT_PATH=/usr $export UIC=$QT_PATH/bin/uic $export MOC=$QT_PATH/bin/moc $export RCC=$QT_PATH/bin/rcc $export CXX=g++ $export CC=gcc Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 4

Gnuplot Installation (2) $export QT_LIBS="-Wl,--no-as-needed /usr/lib/x86_64-linux-gnu/libqt5concurrent.so \ /usr/lib/x86_64-linux-gnu/libqt5core.so /usr/lib/x86_64-linux-gnu/libqt5dbus.so \ /usr/lib/x86_64-linux-gnu/libqt5declarative.so /usr/lib/x86_64-linux-gnu/libqt5gui.so \ /usr/lib/x86_64-linux-gnu/libqt5network.so /usr/lib/x86_64-linux-gnu/libqt5opengl.so \ /usr/lib/x86_64-linux-gnu/libqt5printsupport.so \ /usr/lib/x86_64-linux-gnu/libqt5qml.so \ /usr/lib/x86_64-linux-gnu/libqt5quickparticles.so \ /usr/lib/x86_64-linux-gnu/libqt5quick.so /usr/lib/x86_64-linux-gnu/libqt5quicktest.so \ /usr/lib/x86_64-linux-gnu/libqt5quickwidgets.so \ /usr/lib/x86_64-linux-gnu/libqt5script.so \ /usr/lib/x86_64-linux-gnu/libqt5scripttools.so /usr/lib/x86_64-linux-gnu/libqt5sql.so \ /usr/lib/x86_64-linux-gnu/libqt5svg.so /usr/lib/x86_64-linux-gnu/libqt5test.so \ /usr/lib/x86_64-linux-gnu/libqt5webkit.so \ /usr/lib/x86_64-linux-gnu/libqt5webkitwidgets.so \ /usr/lib/x86_64-linux-gnu/libqt5widgets.so /usr/lib/x86_64-linux-gnu/libqt5xml.so" Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 5

Gnuplot Installation (3) $export QT_CFLAGS="-F$QT_PATH -I/usr/include/x86_64-linux-gnu/qt5 \ -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent \ -I/usr/include/x86_64-linux-gnu/qt5/QtCore \ -I/usr/include/x86_64-linux-gnu/qt5/QtDBus \ -I/usr/include/x86_64-linux-gnu/qt5/QtDeclarative \ -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork \ -I/usr/include/x86_64-linux-gnu/qt5/QtOpenGL \ -I/usr/include/x86_64-linux-gnu/qt5/QtOpenGLExtensions \ -I/usr/include/x86_64-linux-gnu/qt5/QtPlatformHeaders \ -I/usr/include/x86_64-linux-gnu/qt5/QtPrintSupport \ -I/usr/include/x86_64-linux-gnu/qt5/QtQml -I/usr/include/x86_64-linux-gnu/qt5/QtQuick \ -I/usr/include/x86_64-linux-gnu/qt5/QtQuickParticles \ -I/usr/include/x86_64-linux-gnu/qt5/QtQuickTest \ -I/usr/include/x86_64-linux-gnu/qt5/QtQuickWidgets \ -I/usr/include/x86_64-linux-gnu/qt5/QtScript \ -I/usr/include/x86_64-linux-gnu/qt5/QtScriptTools \ -I/usr/include/x86_64-linux-gnu/qt5/QtSql -I/usr/include/x86_64-linux-gnu/qt5/QtTest \ -I/usr/include/x86_64-linux-gnu/qt5/QtWebKit \ -I/usr/include/x86_64-linux-gnu/qt5/QtWebKitWidgets \ -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtSvg \ -I/usr/include/x86_64-linux-gnu/qt5/QtXml" Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 6

Gnuplot Installation (4) Hack the qtterminal of Gnuplot: Create a public function QLabel * getstatuslabel() const returning m_statuslabel private member in QtGnuplotWidget class (src/qtterminal/qtgnuplotwidget.h & src/qtterminal/qtgnuplotwidget.cpp) add #include <cmath> in src/qtterminal/qt_conversion.cpp delete demo subdir from SUBDIRS variable in Makefile with editor (in Gnuplot root path) Run the following commands within Gnuplot root path: $make $sudo make install download QtExample.zip from e class and unzip in a proper dir $qtcreator open QtExample project Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 7

Qt 5 Tutorial Qt modules: Qt Library: C++ class library providing application building blocks and GUI widget classes Qt Creator: An IDE for Qt Applications Qt Designer: A tool of Qt Creator for designing GUIs, generating.ui xml files qmake: tool for generating Makefile There is a plug in for Eclipse IDE Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 8

Qt Creator: Hello world project Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 9

Hello World project (cont.d) Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 10

Hello World project (cont.d) Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 11

Hello World: main function Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 12

Hello World: main function (cont.d) The QApplication object contains the main event loop, where all events from the window system, the keyboard, the mouse, etc. are processed and dispatched. There is only one QApplication object in a Qt GUI application. app.exec(); makes the QApplication enter is event loop. The application is compiled and executed with the first green Play button. The Play button with the bug initiates a debugging session. The Hammer button builds the project In order to build the project from command line run: $qmake (generates the Makefile) $make Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 13

Hello World: main function (cont.d) A Qt GUI component is defined in the main class after the QApplication Usually the main window of the app is defined here HelloWorld class inherits QMainWindow class The main window is shown with the call: w.show(); QMainWindow inherits QWidget class Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 14

Qt Class Hierarchy (fragment) Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 15

Project configuration file Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 16

Project configuration file (cont.d) QT: indicates what libraries are used in the project TARGET: indicates the name of the application TEMPLATE: indicates the build type (app or library) SOURCES / HEADERS: source and header files of the app (apart from generated ones) FORMS: xml files representing the GUI structure of a widget Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 17

Qt Designer Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 18

Qt Designer GUI components (widgets) can be added to a window with Qt Designer. Widgets are added with drag and drop. Widget design properties can be set by the property editor shown in the lower left side of Qt Designer view. Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 19

Generated helloworld.ui file Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 20

HelloWorld class definition Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 21

HelloWorld class definition (cont.d) Qt extends C++ with a meta object system allowing run time introspection which enables the signal slot object communication mechanism, dynamic properties, etc. GUI components must contain the Q_OBJECT macro to support the extensions. The moc meta object compiler reads the C++ header file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta object code for those classes. Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 22

HelloWorld class definition (cont.d) The explicit keyword in the constructor prevents implicit conversions to instantiate an object The constructor argument defines the parent of a QObject. Thus, object hierarchies are created. Object hierarchies are part of Qt memory management. When a parent QObject is deleted, all its children in the hierarchy are also deleted. Child GUI components are rendered in the same window. The code for the Ui::HelloWorld class is generated by uic (User Interface Compiler) according to the ui xml file. Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 23

Generated UI header file Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 24

HelloWorld class implementation Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 25

HelloWorld implementation (cont.d) The constructor of HelloWorld invokes the constructors of QMainWindow and Ui::HelloWorld generated class. The User Interface components are initialized with setupui(this) invocation. Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 26

Signals and Slots The communication between objects is performed through the signal slot mechanism. Signals are emitted from objects when specific events happen. Qt widgets have predefined signals. Widgets are subclassed to add user defined signals. Signals are public access functions in a QObject with no return types (return void). It is recommended to emit them only from the class itself and its subclasses. Signals are automatically generated by the meta object compiler and must not be implemented in the.cpp file Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 27

Signals and Slots Slots are normal member C++ functions declared as slots. A slot is called when a signal connected to it is emitted. Slots are called when a connected signal is emitted regardless of their access level (even if private). The signature of a signal must match the signature of the receiving slot. Signals are connected with slots through the call of: QObject::connect(const QObject * sender, const char * signal, const QObject * receiver, const char * method, Qt::ConnectionType type = Qt::AutoConnection) There are slots automatically connected with signals through the user interface compiler (according to standard naming conventions) Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 28

Signal / Slot example #include <QObject> class Counter : public QObject { Q_OBJECT public: Counter() { m_value = 0; } int value() const { return m_value; } public slots: void setvalue(int value); signals: void valuechanged(int newvalue); private: int m_value; }; void Counter::setValue(int value) { if (value!= m_value) { m_value = value; emit valuechanged(value); } }... Counter a, b; QObject::connect(&a,&Counter::valueChanged, &b, &Counter::setValue); /*a.value() == 12, b.value() == 12*/ a.setvalue(12); /* a.value() == 12, b.value() == 48*/ b.setvalue(48);... Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 29

Signal / Slot automatic connection Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 30

Signal / Slot automatic connection (2) Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 31

Event system In Qt, events are objects, derived from the abstract QEvent class, that represent things that have happened either within an application or as a result of outside activity that the application needs to know about. Standard event classes: QResizeEvent, QPaintEvent, QMouseEvent, QKeyEvent, and QCloseEvent The normal way for an event to be delivered is by calling a virtual function. If you do not perform all the necessary work in your implementation of the virtual function, you may need to call the base class's implementation. Events are delivered to a specific QObject according to their context. Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 32

Event handler example void MyCheckBox::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { // handle left mouse button here } else { // pass on other buttons to base class QCheckBox::mousePressEvent(event); } } Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 33

Event filters Sometimes an object needs to look at, and possibly intercept, the events that are delivered to another object. Visualization::Visualization(QWidget *parent) : QMainWindow(parent), ui(new Ui::Visualization) { ui->setupui(this); widget = new QtGnuplotWidget(); widget->installeventfilter(this); widget->setstatuslabelactive(true); instance = new QtGnuplotInstance(); instance->setwidget(widget); } Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 34

Event filters (2) bool Visualization::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { if (obj == this->widget) { QMouseEvent *mouseevent = static_cast<qmouseevent *>(event); if (mouseevent->button() == Qt::LeftButton) { ui->outputtxt->settext( this->widget->getstatuslabel()->text()); } } } return QObject::eventFilter(obj, event); } Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 35

QtGnuplot QtGnuplot library provides 2 basic classes: QtGnuplotWidget (subclass of QWidget) QtGnuplotInstance The first class is a QWidget where Gnuplot plots are painted. The second class is an interface to the Gnuplot program Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 36

QtGnuplot example Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 37

QtGnuplot example (2) The uncommented line plots a circle. In order to do that we take the contour line of the function z = f(x,y) at z = 0 The commented line plots a point in a 2 dimensional diagram. Documentation concerning Gnuplot commands can be found in: http://www.gnuplot.info/docs_4.0/gpcard.pdf Helpful material can be found in: http://www.gnuplotting.org/plotting single points/ and http://www.gnuplotting.org/plotting data/ Κ23γ Ανάπτυξη Λογισμικού για Αλγοριθμικά Προβλήματα: Φροντιστήριο 38