OO for GUI Design (contd.) Questions:

Size: px
Start display at page:

Download "OO for GUI Design (contd.) Questions:"

Transcription

1 OO for GUI Design (contd.) Questions: 1

2 1. What is a window manager and what are its responsibilities? 2

3 2. How would you define an event in the context of GUI programming? 3

4 3. What is the first thing your GUI program does when its event processing loop discovers a new event in the event queue? 4

5 4. What is a callback function? 5

6 5. How does AWT/Swing designate objects for receiving events emitted by GUI components? To elaborate, if you click a GUI button, it emits an event of type ActionEvent. What kinds of objects can trap such events? 6

7 6. How does AWT/Swing establish a connection between the GUI component that emits an event and the object that traps the event? 7

8 7. What is an adapter class in AWT/Swing? 8

9 Event Processing in C++ Qt As in Java, Qt also makes a distinction between low-level and high-level events. But, whereas Java treats all events in the same way, Qt uses different methods for low-level events and for high-level events. High-level events in Qt are processed by the signal-slot mechanism. On the other hand, the low-level events are handled through the mechanism of virtual functions. 9

10 QObject::connect( pointertowidgetemittingsignal, SIGNAL( signalname( paramtypeonly ) ), pointertoobjectreceivingsignal, SLOT( slotname( paramtypeonly ) ) ); 10

11 QApplication myapp( argc, argv ); //argc, argv from main h QPushButton* mybutton = new QPushButton( "Quit"); QObject::connect( mybutton, SIGNAL( clicked() ), &myapp, SLOT( quit() ) ); QObject::connect( mymenu, SIGNAL( activated( int ) ), pointertoobjectreceivingsignal, SLOT( slotdomenufunction( int ) ) ); 11

12 Using pre-defined classes with signals and slots: 12

13 #include <qapplication.h> #include <qslider.h> #include <qlcdnumber.h> int main( int argc, char **argv ) { QApplication myapp( argc, argv ); QWidget* mywidget= new QWidget(); mywidget->setgeometry( 400, 300, 170, 110 ); // (A) // (B) // (C) QSlider* myslider = new QSlider( 0, // minimum value // (D) 9, // maximum value // (E) 1, // step // (F) 1, // initial value // (G) QSlider::Horizontal, // orient. // (H) mywidget ); // parent // (I) myslider->setgeometry( 10, 10, 150, 30 ); // (J) QLCDNumber* mylcdnum = new QLCDNumber( 1, // number of digits mywidget );// parent // (K) mylcdnum->setgeometry( 60, 50, 50, 50 ); // (L) mylcdnum->display( 1 ); // manual invocation of slot // (M) // connect slider and number display QObject::connect( myslider, SIGNAL( valuechanged( int ) ), mylcdnum, SLOT( display( int ) ) ); myapp.setmainwidget( mywidget ); mywidget->show(); return myapp.exec(); // starts processing of event loop // (N) // (O) // (P) // (Q) 13

14 } 14

15 g++ -o SignalSlotDemo SignalSlotDemo.cc -I$QTDIR/include -L$QTDIR 15

16 Communicating Events to Other Components in C++ Qt class MyClass : public QObject { }; Q_OBJECT //.. signals: void userdidsomething(); // other signals.. public slots: void dosomethingreacttosignal(); // other public slots.. private slots: void dosomethinginternally(); // other private slots // rest of code 16

17 Qt has a special procedure for compiling classes that contain signals and slots. Before regular compilation, such classes must first be run through a meta object compiler, moc. The meta object compiler generates what is known as the glue code needed for the signal/slot mechanism to work. The output of moc compilation is another source file which consists of the meta object code for the classes with signals and slots. 17

18 Compilation of a Qt class with signals and/or slots: 1. Separate the class declaration from its implementation. So if MyWidget has signals and/or slots, create the following three files: MyWidget.h MyWidget.cc main.cc 2. Run the declaration file, MyWidget.h, through the meta object compiler, moc. The moc compiler will output a source file containing meta object code. The name of the output file will be moc MyWidget.cc. 3. Now compile the meta object file moc MyWidget.cc to create the binary file moc MyWidget.o. 4. Compile the implementation source file MyWidget.cc to create the binary file MyWidget.o. 5. Compile the source file main.cc to create a binary file main.o. 6. Link the binary files moc MyWidget.o, MyWidget.o and main.o to create the executable. 18

19 User enters a character in the MyEditWindow object V The text window emits the signal textchaged() inherited by MyEditWindow from QMultiLineEdit class > signal to slot connection established in MyEditWindow class V Signal textchanged() trapped by the slot function dosomethingtextchanged() of MyEditWindow class V The slot function dosomethingtextchanged() strings together the chars typed by user and checks for color names. If word is a color name, emits the signal usertypedkeyword( char* ) 19

20 > siginal to slot connection established in CrazyWindow class V The signal usertypedkeyword( char* ) emitted by MyEditWindow object trapped by the slot function drawforkeyword( char* ) of the MyDrawWindow object 20

21 /////////////// file: CrazyWindow.h /////////////// #ifndef CRAZYWINDOW_H #define CRAZYWINDOW_H #include <qwidget.h> class CrazyWindow: public QWidget { public: CrazyWindow( QWidget *parent=0, const char* name= 0 ); }; #endif 21

22 /////////////// file: CrazyWindow.cc /////////////// #include "CrazyWindow.h" #include <qpainter.h> #include <qlayout.h> #include "MyEditWindow.h" #include "MyDrawWindow.h" CrazyWindow::CrazyWindow( QWidget* parent, const char* name ) : QWidget( parent, name ) { // QHBoxLayout* layout = new QHBoxLayout( this, -1 ); // layout->setautoadd( TRUE ); QGridLayout* grid = new QGridLayout( this, 0, 1 ); MyEditWindow* editwin = new MyEditWindow( this, "for text only" ); MyDrawWindow* drawwin = new MyDrawWindow( this, "for pictures only" ); grid->addwidget( editwin, 0, 0 ); grid->addwidget( drawwin, 0, 1 ); } QObject::connect( editwin, SIGNAL( usertypedkeyword( char* ) ), drawwin, SLOT( drawforkeyword( char* ) ) ); 22

23 //////////////// file: MyEditWindow.h /////////////// #ifndef MYEDITWINDOW_H #define MYEDITWINDOW_H #include <qmultilineedit.h> class MyEditWindow: public QMultiLineEdit { Q_OBJECT public: MyEditWindow( QWidget *parent=0, const char* name= 0 ); signals: void usertypedkeyword( char* ); public slots: void dosomethingtextchanged(); private: QString word; }; #endif 23

24 //////////////// file: MyEditWindow.cc /////////////// #include "MyEditWindow.h" #include <qtextstream.h> #include <stdlib.h> // for malloc() MyEditWindow::MyEditWindow( QWidget* parent, const char* name ) : QMultiLineEdit( parent, name ) { word = QString( "" ); setpalette( QPalette( QColor( 250, 250, 200 ) ) ); } QObject::connect( this, SIGNAL( textchanged() ), this, SLOT( dosomethingtextchanged( ) ) ); void MyEditWindow::doSomethingTextChanged() { QString qstr = text(); QChar c = qstr[ (int) qstr.length() - 1 ]; if ( c == ) { if ( word == "red" word == "blue" word == "orange" word == "green" ) { char* keyword = (char*) malloc( word.length() + 1 ); strcpy( keyword, word ); emit( usertypedkeyword( keyword ) ); } word = QString( "" ); 24

25 } } else word += c ; 25

26 QSizePolicy MyDrawWindow::sizePolicy() const { return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expan } 26

27 //////////////// file: MyDrawWindow.h /////////////// #ifndef MYDRAWWINDOW_H #define MYDRAWWINDOW_H #include <qwidget.h> class MyDrawWindow: public QWidget { Q_OBJECT public: MyDrawWindow( QWidget *parent=0, const char* name= 0 ); QSizePolicy sizepolicy() const; void paintevent( QPaintEvent* ); public slots: void drawforkeyword( char* ); }; #endif 27

28 //////////////// file: MyDrawWindow.cc /////////////// #include "MyDrawWindow.h" #include <string.h> #include <qpainter.h> #include <qwidget.h> #include <stdlib.h> #include <time.h> // for rand() // for time(null) to seed rand() MyDrawWindow::MyDrawWindow( QWidget* parent, const char* name ) : QWidget( parent, name ) { setpalette( QPalette( QColor( 250, 250, 200 ) ) ); srand( (unsigned) time(null) ); } void MyDrawWindow::paintEvent( QPaintEvent* ) { QPainter p( this ); } void MyDrawWindow::drawForKeyword( char* key ) { QPainter p( this ); p.setbrush( QString( key ) ); p.setpen( NoPen ); int x = rand() % ; int y = rand() % ; p.drawrect( QRect( x, y, 30, 30 ) ); 28

29 } QSizePolicy MyDrawWindow::sizePolicy() const { return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); } 29

30 /////////////// file: main_crazywindow.cc ///////////// #include <qapplication.h> #include "CrazyWindow.h" int main( int argc, char ** argv ) { QApplication::setColorSpec( QApplication::CustomColor ); QApplication a( argc, argv ); } CrazyWindow w; w.setgeometry( 0, 0, 700, 500 ); a.setmainwidget( &w ); w.show(); a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ); return a.exec(); 30

31 make -f Makefile_CrazyWindow 31

32 CC=g++ LDLIBS=-L/home/kak/qt/qt/qt-2.2.3/lib -lqt CFLAGS=-g -I/home/kak/qt/qt/qt-2.2.3/include CrazyWindow: moc_crazywindow.o moc_mydrawwindow.o moc_myeditwindow.o \ CrazyWindow.o MyDrawWindow.o MyEditWindow.o \ main_crazywindow.o Makefile_CrazyWindow $(CC) $(LDLIBS) -o CrazyWindow moc_crazywindow.o \ moc_mydrawwindow.o moc_myeditwindow.o CrazyWindow.o \ MyDrawWindow.o MyEditWindow.o main_crazywindow.o moc_crazywindow.cc: CrazyWindow.h moc -o moc_crazywindow.cc CrazyWindow.h moc_mydrawwindow.cc: MyDrawWindow.h moc -o moc_mydrawwindow.cc MyDrawWindow.h moc_myeditwindow.cc: MyEditWindow.h moc -o moc_myeditwindow.cc MyEditWindow.h moc_crazywindow.o: moc_crazywindow.cc $(CC) -c $(CFLAGS) -O2 moc_crazywindow.cc moc_mydrawwindow.o: moc_mydrawwindow.cc $(CC) -c $(CFLAGS) -O2 moc_mydrawwindow.cc moc_myeditwindow.o: moc_myeditwindow.cc $(CC) -c $(CFLAGS) -O2 moc_myeditwindow.cc CrazyWindow.o: CrazyWindow.cc $(CC) -c $(CFLAGS) -O2 CrazyWindow.cc MyDrawWindow.o: MyDrawWindow.cc $(CC) -c $(CFLAGS) -O2 MyDrawWindow.cc MyEditWindow.o: MyEditWindow.cc $(CC) -c $(CFLAGS) -O2 MyEditWindow.cc main_crazywindow.o: main_crazywindow.cc $(CC) -c $(CFLAGS) -O2 main_crazywindow.cc 32

33 clean: rm -f CrazyWindow rm -f *.o rm -f moc*.* 33

34 Summary of Facts about Signals and Slots You never have to implement signals directly. You just declare them. In other words, there is no implementation code associated with the signals. Slots are declared and implemented just like any other C++ method. They can also be called and used like the other more traditional methods. A slot will generally be public, but you can make it protected. It does not make much sense for a slot to be private. A slot function can be virtual. A slot function cannot be static. You can connect any number of slots to a signal, and you can connect any number of signals to a slot. 34

35 If more than one slot is connected to a signal, the order in which the slots are called is not guaranteed. In order to be connected to a signal, a slot must have the same parameter types as the signal. Signals and slots are only available within a C++ class; you cannot make a stand-alone function a slot. Every class that wants to define its own signals or slots must be derived, directly or indirectly, from QObject. Every class that wants to define its own signals or slots must contain the macro Q OBJECT somewhere. Do not put a semicolon after the Q OBJECT macro because some compilers will choke on this. 35

36 Event Processing in GNOME/GTK+ gtk_signal_connect( GTK_OBJECT( mybutton ), "clicked", GTK_SIGNAL_FUNC( sayhello ), NULL ); 36

37 #include <gnome.h> gint eventdestroy( GtkWidget* widget, GdkEvent* event, gpointer data ); void sayhello( GtkWidget* widget, GdkEvent* event, gpointer data ); int main( int argc, char* argv[] ) { GtkWidget* window; GtkWidget* mybutton; gnome_init( "hellobutton", "1.0", argc, argv ); window = gnome_app_new( "hellobutton", "Window with Hello Button" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 100 ); gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( eventdestroy ), NULL ); mybutton = gtk_button_new_with_label( "Say Hello" ); gtk_signal_connect( GTK_OBJECT( mybutton ), "clicked", GTK_SIGNAL_FUNC( sayhello ), NULL ); gnome_app_set_contents( GNOME_APP( window ), mybutton ); } gtk_widget_show_all( window ); gtk_main(); exit( 0 ); 37

38 void sayhello( GtkWidget* widget, GdkEvent* event, gpointer data ) { g_print( "Hello from Gnome/GTK+\n" ); } gint eventdestroy( GtkWidget* widget, GdkEvent* event, gpointer data ) { gtk_main_quit(); return 0; } 38

39 Communicating Events to Other Components in Gnome/Gtk+ 39

40 #include <gnome.h> #include <stdio.h> #include <stdlib.h> #include <time.h> // for rand() // for seed for rand() GtkWidget* maketable(); gint eventdestroy( GtkWidget* widget, GdkEvent* event, gpointer data ); void eventtextentered( GtkWidget* widget, GdkEvent* event, gpointer data ); char* word = NULL; // for the keyword GtkWidget* textarea; // for panel1 GtkWidget* canvas; // for panel2 GnomeCanvasGroup* rootgroup; // for canvas for panel2 GnomeCanvasItem* item; // for canvas for panel2 40

41 int main( int argc, char* argv[] ) { GtkWidget* window; GtkWidget* table; gnome_init( "aspect", "1.0", argc, argv ); srand( (unsigned) time( NULL ) ); window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_default_size( GTK_WINDOW( window ), 300, 200 ); gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( eventdestroy ), NULL ); table = maketable(); gtk_container_add( GTK_CONTAINER( window ), table ); } gtk_widget_show_all( window ); gtk_main(); exit( 0 ); GtkWidget* maketable() { GtkWidget* table = gtk_table_new( 1, 2, TRUE ); GtkWidget* panel1; GtkWidget* panel2; // panel1: 41

42 panel1 = gtk_scrolled_window_new( NULL, NULL ); textarea = gtk_text_new( NULL, NULL ); gtk_text_set_line_wrap( (GtkText*) textarea, FALSE ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( panel1 ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( panel1 ), textarea ); gtk_text_set_editable( (GtkText*) textarea, TRUE ); gtk_table_attach_defaults( GTK_TABLE( table ), panel1, 0, 1, 0, 1 ); gtk_widget_show( panel1 ); gtk_signal_connect( GTK_OBJECT( textarea ), "insert-text", GTK_SIGNAL_FUNC( eventtextentered ), NULL ); // panel2: panel2 = gtk_scrolled_window_new( NULL, NULL ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( panel2 ), GTK_POLICY_NEVER, GTK_POLICY_NEVER); canvas = gnome_canvas_new(); gtk_widget_set_usize( canvas, 100, 100 ); rootgroup = gnome_canvas_root( GNOME_CANVAS( canvas ) ); gtk_container_add( GTK_CONTAINER( panel2 ), canvas ); gtk_table_attach_defaults( GTK_TABLE( table ), panel2, 1, 2, 0, 1 ); } return table; 42

43 gint eventdestroy( GtkWidget* widget, GdkEvent* event, gpointer data ) { gtk_main_quit(); return 0; } void eventtextentered( GtkWidget* widget, GdkEvent* event, gpointer data ) { double xpos; double ypos; gint end_pos = gtk_editable_get_position( (GtkEditable*) widget ); gchar* str = gtk_editable_get_chars( (GtkEditable*) widget, end_pos - 1, -1 ); if ( word == NULL ) { word = malloc( 50 ); *word = \0 ; } if ( str!= NULL ) { if ( *str == ) { if ( strcmp( word, "red" ) == 0 ) { xpos = rand() %75; ypos = rand() %75; //printf( "xpos: %f ypos: %f \n", xpos, ypos ); item = gnome_canvas_item_new( rootgroup, gnome_canvas_rect_get_type(), "x1", xpos, "y1", ypos, "x2", xpos , "y2", ypos , "fill_color", "red", "outline_color", "white", 43

44 } NULL ); gnome_canvas_item_show( item ); if ( strcmp( word, "green" ) == 0 ) { xpos = rand() %75; ypos = rand() %75; //printf( "xpos: %f ypos: %f \n", xpos, ypos ); item = gnome_canvas_item_new( rootgroup, gnome_canvas_rect_get_type(), "x1", xpos, "y1", ypos, "x2", xpos , "y2", ypos , "fill_color", "green", "outline_color", "white", NULL ); gnome_canvas_item_show( item ); } if ( strcmp( word, "blue" ) == 0 ) { xpos = rand() %75; ypos = rand() %75; //printf( "xpos: %f ypos: %f \n", xpos, ypos ); item = gnome_canvas_item_new( rootgroup, gnome_canvas_rect_get_type(), "x1", xpos, "y1", ypos, "x2", xpos , "y2", ypos , "fill_color", "blue", "outline_color", "white", NULL ); gnome_canvas_item_show( item ); } 44

45 if ( strcmp( word, "magenta" ) == 0 ) { xpos = rand() %75; ypos = rand() %75; //printf( "xpos: %f ypos: %f \n", xpos, ypos ); item = gnome_canvas_item_new( rootgroup, gnome_canvas_rect_get_type(), "x1", xpos, "y1", ypos, "x2", xpos , "y2", ypos , "fill_color", "magenta", "outline_color", "white", NULL ); gnome_canvas_item_show( item ); } } word = NULL; gnome_canvas_update_now( (GnomeCanvas*) canvas ); } else strcat( word, str ); } g_free( str ); 45

46 CC=gcc LDLIBS= gnome-config --libs gnomeui CFLAGS=-Wall -g gnome-config --cflags gnomeui crazywindow: crazywindow.o Makefile_crazywindow $(CC) $(LDLIBS) crazywindow.o -o crazywindow crazywindow.o: crazywindow.c $(CC) $(CFLAGS) -c crazywindow.c clean: rm -f crazywindow rm -f crazywindow.o 46

47 Summary of Facts about Callback Functions in Gnome/Gtk+ 1. The callback function you write for a given signal must have its return type and the argument types and number that match exactly those that are specified for the signal. 2. The header format of a callback function is not standardized. 3. Since the call to a callback function is generated at runtime, there is no way for a compiler to make sure that your callback function has the correct return type and the number of arguments. All that the compiler can do is to make sure that the header of your callback function matches the prototype you might have defined at the beginning of your file. In fact, at compile time, the system does not really know that what you have written as a callback function is really a callback function. To the compiler, it is like any other function. However, at runtime, when the function gtk signal connect() is invoked and the name of the callback function is encountered as one of the arguments, the system knows that it is dealing with a callback function. It is at that time that the system first checks that your callback function meets the specifications for the signal in question. 47

48 4. Each widget class defines its own set of signals. For example, the classgtkbutton has defined for it directly the following five signals: clicked pressed released enter leave 5. A widget class also inherits all the signals from all its parent classes. GtkButton inherits from GtkBin, GtkContainer, GtkWidget, and GtkObject. GtkBin has no signals defined for it directly, GtkContainer has 5, GtkWidget 54, and GtkObject 1. So GtkButton inherits 60 signals from its parents. Together with its own 5, GtkButton has 65 signals. 6. Every callback function has at least the two parameters, but many have many more. The prototype of the simplest callback function looks like void callback( GtkWidget*, gpointer ); 48

49 7. If a callback function has additional parameters, they will always be between these two standard ones. For example, a callback function that includes a GdkEvent* in its parameter list is void callback( GtkWidget*, GdkEvent*, gpointer ); 8. A callback function will have one of the following return types void gint gboolean 9. Here is a prototype of a callback function for the signal drag drop that returns a gboolean: gboolean callback( GtkWidget*, GtkDragContext*, gint, gint, guint, gpointer ); 49

50 10. When a new widget is constructed at run time, the signals for that widget are automatically registered by entering them into an internal table. Each signal is assigned an ID number in this table. The entries in this table can be queried by invoking gtk_signal_query( i ) This will return the information on the signal which was assigned the ID number i. The returned information is a pointer to a struct of type GtkSignalQuery. 11. The GtkSignalQuery structure returned by gtk signal query(i) contains the following fields object_type return_val signal_name nparams params[j] 12. The following invocations on the fields listed in the previous item return the information shown gtk_type_name( q->object_type ) returns the name of the object for which the signal is directly defined 50

51 gtk_type_name( q->return_val ) inheritance( q->object_type ) returns the type of the return value from the callback function returns a single string composed of all the parents all the way back to GtkObject Note: inheritance() is defined locally 13. It is difficult to keep up with the formats of all the callback functions, especially because their specifications are not presented in one place. 51

EE495K Slides by Avi Kak: OO for GUI Design (contd.)

EE495K Slides by Avi Kak: OO for GUI Design (contd.) EE495K Slides by Avi Kak: OO for GUI Design (contd.) 1 Date: Tue, 18 Feb 2003 09:42:33 CST To: kak@ecn.purdue.edu From: Newton Matthew-W18732 Subject: RE: Visit to Purdue! Return-Path:

More information

Lecture 3. GUI Programming part 1: GTK

Lecture 3. GUI Programming part 1: GTK INTRODUCTION TO DESIGN AUTOMATION Lecture 3. GUI Programming part 1: GTK Guoyong Shi, PhD shiguoyong@ic.sjtu.edu.cn School of Microelectronics Shanghai Jiao Tong University Fall 2010 2010-9-15 Slide 1

More information

EE495K Slides by Avi Kak: OO for GUI Design (contd.) Questions:

EE495K Slides by Avi Kak: OO for GUI Design (contd.) Questions: EE495K Slides by Avi Kak: OO for GUI Design (contd.) Questions: 1 1. What are the two features of every GUI program in Qt? 2 2. How are the parent-child connections established in the containment hierarchy

More information

C++ GUI Programming with Qt 3

C++ GUI Programming with Qt 3 Welcome from Budapest Welcome from ELTE University 1 Rozália Szabó Nacsa Eötvös Loránd University, Budapest Faculty of Informatics nacsa@inf.elte.hu 2 Qt Overview Qt is a complete C++ application development

More information

Creating GNOME Applications with Glade. Part I: Introduction

Creating GNOME Applications with Glade. Part I: Introduction Creating GNOME Applications with Glade Part I: Introduction Glade 3 Glade 3 is a tool to enable quick and easy development of Uis for the GTK+ toolkit and GNOME desktop environment. User interfaces designed

More information

Lesson 2: GTK+ Basics

Lesson 2: GTK+ Basics 1 A First GTK+ Program We will begin with a very simple GTK+ program in order to demonstrate some of the key tasks that every GTK+ main program must perform. The program, hello_world.c, is found in many

More information

The FFI Reference Manual

The FFI Reference Manual The FFI Reference Manual a Foreign Function Interface (version 0.2) for MIT/GNU Scheme version 9.0.1 2011-09-19 by Matt Birkholz This manual documents FFI 0.2. Copyright c 1986, 1987, 1988, 1989, 1990,

More information

Lab 12: GUI programming with Qt

Lab 12: GUI programming with Qt 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)

More information

Qt Essentials - Objects Module

Qt Essentials - Objects Module Qt Essentials - Objects Module Training Course Visit us at http://qt.digia.com Produced by Digia Plc. Material based on Qt 5.0, created on September 27, 2012 Digia Plc. Module: Signals & Slots Event Handling

More information

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

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26, SERIOUS ABOUT SOFTWARE Qt Core features Timo Strömmer, May 26, 2010 1 Contents C++ refresher Core features Object model Signals & slots Event loop Shared data Strings Containers Private implementation

More information

Open source MySQL Browser for Open Innovation

Open source MySQL Browser for Open Innovation Open source MySQL Browser for Open Innovation Lecturer Radu Bucea-Manea-Tonis, PhD 1 1 mysqlbrowser.codeplex.com Abstract. Our purpose is to cross-compile MySQL driver source code for Linux on Windows

More information

Programming with Clutter. Murray Cumming

Programming with Clutter. Murray Cumming Programming with Clutter Murray Cumming Programming with Clutter by Murray Cumming Copyright 2007, 2008 Openismus GmbH We very much appreciate any reports of inaccuracies or other errors in this document.

More information

C Libraries. Using GLib. Ph. D. Eng. Lucjan Miękina upel.agh.edu.pl/wimir/login/ Department of Robotics and Mechatronics 1/31

C Libraries. Using GLib. Ph. D. Eng. Lucjan Miękina upel.agh.edu.pl/wimir/login/ Department of Robotics and Mechatronics 1/31 1/31 C Libraries Using GLib Ph. D. Eng. Lucjan Miękina upel.agh.edu.pl/wimir/login/ Department of Robotics and Mechatronics January 10, 2017 2/31 Programming in C External libraries - GLib If you re writing

More information

Contents ROOT/Qt Integration Interfaces

Contents ROOT/Qt Integration Interfaces Contents 1 ROOT/Qt Integration Interfaces 3 1.1 Qt-ROOT Implementation of TVirtualX Interface (BNL)......................... 3 1.1.1 Installation............................................... 3 1.1.2

More information

EE495K Slides by Avi Kak: OO for GUI Design (second lecture) Questions:

EE495K Slides by Avi Kak: OO for GUI Design (second lecture) Questions: EE495K Slides by Avi Kak: OO for GUI Design (second lecture) Questions: 1 1. Much of the history of modern GUI programming can be traced back to X. What is X and what was it mainly intended for? 2 2. What

More information

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine

More information

Kurt Schmidt. October 30, 2018

Kurt Schmidt. October 30, 2018 to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed

More information

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

Tutorial 1 C Tutorial: Pointers, Strings, Exec

Tutorial 1 C Tutorial: Pointers, Strings, Exec TCSS 422: Operating Systems Institute of Technology Spring 2017 University of Washington Tacoma http://faculty.washington.edu/wlloyd/courses/tcss422 Tutorial 1 C Tutorial: Pointers, Strings, Exec The purpose

More information

Container Widgets and Packing

Container Widgets and Packing Container Widgets and Packing As mentioned in Chapter 2, there are two kinds of containers, those that can hold no more than one child widget, and those that can hold more than one. Containers that can

More information

Cake: a tool for adaptation of object code

Cake: a tool for adaptation of object code Cake: a tool for adaptation of object code Stephen Kell Stephen.Kell@cl.cam.ac.uk Computer Laboratory University of Cambridge Cake... p.1/32 Some familiar problems Software is expensive to develop expensive

More information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

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

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems Deep C Multifile projects Getting it running Data types Typecasting Memory management Pointers Fabián E. Bustamante, Fall 2004 Multifile Projects Give your project a structure Modularized design Reuse

More information

C: Arrays, and strings. Department of Computer Science College of Engineering Boise State University. September 11, /16

C: Arrays, and strings. Department of Computer Science College of Engineering Boise State University. September 11, /16 Department of Computer Science College of Engineering Boise State University September 11, 2017 1/16 1-dimensional Arrays Arrays can be statically declared in C, such as: int A [100]; The space for this

More information

Praktische Aspekte der Informatik

Praktische Aspekte der Informatik Praktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor https://graphics.tu-bs.de/teaching/ws1718/padi/ 1 Your Proposal It s due 17.11.2017! https://graphics.tu-bs.de/teaching/ws1718/padi/

More information

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3). cs3157: another C lecture (mon-21-feb-2005) C pre-processor (1). today: C pre-processor command-line arguments more on data types and operators: booleans in C logical and bitwise operators type conversion

More information

Final CSE 131B Spring 2004

Final CSE 131B Spring 2004 Login name Signature Name Student ID Final CSE 131B Spring 2004 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 (25 points) (24 points) (32 points) (24 points) (28 points) (26 points) (22 points)

More information

CSCI-243 Exam 2 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCI-243 Exam 2 Review February 22, 2015 Presented by the RIT Computer Science Community CSCI-43 Exam Review February, 01 Presented by the RIT Computer Science Community http://csc.cs.rit.edu C Preprocessor 1. Consider the following program: 1 # include 3 # ifdef WINDOWS 4 # include

More information

Maemo Diablo Source code for the LibOSSO RPC examples Training Material

Maemo Diablo Source code for the LibOSSO RPC examples Training Material Maemo Diablo Source code for the LibOSSO RPC examples Training Material February 9, 2009 Contents 1 Source code for the LibOSSO RPC examples 2 1.1 libosso-example-sync/libosso-rpc-sync.c..............

More information

JTSK Programming in C II C-Lab II. Lecture 3 & 4

JTSK Programming in C II C-Lab II. Lecture 3 & 4 JTSK-320112 Programming in C II C-Lab II Lecture 3 & 4 Xu (Owen) He Spring 2018 Slides modified from Dr. Kinga Lipskoch Planned Syllabus The C Preprocessor Bit Operations Pointers and Arrays (Dynamically

More information

Functions in C C Programming and Software Tools. N.C. State Department of Computer Science

Functions in C C Programming and Software Tools. N.C. State Department of Computer Science Functions in C C Programming and Software Tools N.C. State Department of Computer Science Functions in C Functions are also called subroutines or procedures One part of a program calls (or invokes the

More information

QT/KDE Research Paper CS B 27 February 2002

QT/KDE Research Paper CS B 27 February 2002 QT/KDE Research Paper CS 159.3 B 27 February 2002 Submitted by: AY-AD CAJIPE CHAN CHENG MAGDARAOG KDE Facts and Figures KDE is a big project. While it is very hard to quantify what this means exactly,

More information

ECE264 Spring 2014 Exam 2, March 11, 2014

ECE264 Spring 2014 Exam 2, March 11, 2014 ECE264 Spring 2014 Exam 2, March 11, 2014 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.

More information

Dynamic memory allocation

Dynamic memory allocation Dynamic memory allocation outline Memory allocation functions Array allocation Matrix allocation Examples Memory allocation functions (#include ) malloc() Allocates a specified number of bytes

More information

Qt-Based Implementation of Low Level ROOT Graphical Layer

Qt-Based Implementation of Low Level ROOT Graphical Layer Qt-Based Implementation of Low Level ROOT Graphical Layer By V.Fine ROOT Low Level Graphics Level It is well-known that ROOT package has been ported to many different platforms which include the various

More information

Qt Quick From bottom to top

Qt Quick From bottom to top SERIOUS ABOUT SOFTWARE Qt Quick From bottom to top Timo Strömmer, Feb 11, 2011 1 Contents Day 2 Qt core features Shared data objects Object model, signals and slots, properties Hybrid programming QML fluid

More information

C SCI The X Window System Stewart Weiss

C SCI The X Window System Stewart Weiss The X Window System The X Window System is a networking and display protocol which provides windowing on bitmapped displays. X provides the basic framework for building GUI environments, such as drawing

More information

Exercise Session 2 Systems Programming and Computer Architecture

Exercise Session 2 Systems Programming and Computer Architecture Systems Group Department of Computer Science ETH Zürich Exercise Session 2 Systems Programming and Computer Architecture Herbstsemester 216 Agenda Linux vs. Windows Working with SVN Exercise 1: bitcount()

More information

To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows

To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows Unti 4: C Arrays Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type An array is used to store a collection of data, but it is often more useful

More information

Designing Interactive Systems II

Designing Interactive Systems II Designing Interactive Systems II Computer Science Graduate Programme SS 2010 Prof. Dr. RWTH Aachen University http://hci.rwth-aachen.de 1 Review 2 Review Web 2.0 in keywords 2 Review Web 2.0 in keywords

More information

Object-Oriented Programming

Object-Oriented Programming 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

More information

today cs3157-fall2002-sklar-lect05 1

today cs3157-fall2002-sklar-lect05 1 today homework #1 due on monday sep 23, 6am some miscellaneous topics: logical operators random numbers character handling functions FILE I/O strings arrays pointers cs3157-fall2002-sklar-lect05 1 logical

More information

Chapter 14 - Advanced C Topics

Chapter 14 - Advanced C Topics Chapter 14 - Advanced C Topics Outline 14.1 Introduction 14.2 Redirecting Input/Output on UNIX and DOS Systems 14.3 Variable-Length Argument Lists 14.4 Using Command-Line Arguments 14.5 Notes on Compiling

More information

Tutorial 1: Introduction to C Computer Architecture and Systems Programming ( )

Tutorial 1: Introduction to C Computer Architecture and Systems Programming ( ) Systems Group Department of Computer Science ETH Zürich Tutorial 1: Introduction to C Computer Architecture and Systems Programming (252-0061-00) Herbstsemester 2012 Goal Quick introduction to C Enough

More information

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ. C BOOTCAMP DAY 2 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Pointers 2 Pointers Pointers are an address in memory Includes variable addresses,

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Automatically generated type-safe GTK+ binding for Dylan

Automatically generated type-safe GTK+ binding for Dylan Automatically generated type-safe GTK+ binding for Dylan Hannes Mehnert hannes@mehnert.org Dylan Hackers ABSTRACT We present an automated way to get language bindings for GTK+ for Dylan [2], an object-oriented

More information

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Announcements Exam 1 (20%): Feb. 27 (Tuesday) Tentative Proposal Deadline:

More information

C: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36

C: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36 Department of Computer Science College of Engineering Boise State University August 25, 2017 1/36 Pointers and Arrays A pointer is a variable that stores the address of another variable. Pointers are similar

More information

CS 0449 Sample Midterm

CS 0449 Sample Midterm Name: CS 0449 Sample Midterm Multiple Choice 1.) Given char *a = Hello ; char *b = World;, which of the following would result in an error? A) strlen(a) B) strcpy(a, b) C) strcmp(a, b) D) strstr(a, b)

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready.

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready. Name: CSE 303, Winter 2007, Final Examination 15 March 2007 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for two 8.5x11in pieces of paper (both

More information

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

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3 Hello, World! in C Johann Myrkraverk Oskarsson October 23, 2018 Contents 1 The Quintessential Example Program 1 I Printing Text 2 II The Main Function 3 III The Header Files 4 IV Compiling and Running

More information

t GTK+ Object # widget, [ W< z< sl. y Widget E / Xlib E 8 Csq ;, #,., $ Gtk widget object GWuS vv q. A o. # widget x C widget # X L. B #, D #( *), " #

t GTK+ Object # widget, [ W< z< sl. y Widget E / Xlib E 8 Csq ;, #,., $ Gtk widget object GWuS vv q. A o. # widget x C widget # X L. B #, D #( *),  # GTK Tutorial Ian Main imain@gtk.org, Tony Gale gale@gtk.org 1998[ 5 24 ts liberta@cau.ac.kr, hanjiho@penta.co.kr 1998[ 5 25 C 1 < & 2 S B GTK Tutorial. GTK+ W W http://www.gtk. org/.? Z (3/??), Tutorial

More information

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

Review. Designing Interactive Systems II. Introduction. Web 2.0 in keywords GWT Cappuccino HTML5. Cross platform GUI Toolkit Review Designing Interactive Systems II Computer Science Graduate Programme SS 2010 Prof. Dr. RWTH Aachen University Web 2.0 in keywords GWT Cappuccino HTML5 http://hci.rwth-aachen.de 1 2 Introduction

More information

CSCI 2132 Final Exam Solutions

CSCI 2132 Final Exam Solutions Faculty of Computer Science 1 CSCI 2132 Final Exam Solutions Term: Fall 2018 (Sep4-Dec4) 1. (12 points) True-false questions. 2 points each. No justification necessary, but it may be helpful if the question

More information

#include <stdio.h> int main() { char s[] = Hsjodi, *p; for (p = s + 5; p >= s; p--) --*p; puts(s); return 0;

#include <stdio.h> int main() { char s[] = Hsjodi, *p; for (p = s + 5; p >= s; p--) --*p; puts(s); return 0; 1. Short answer questions: (a) Compare the typical contents of a module s header file to the contents of a module s implementation file. Which of these files defines the interface between a module and

More information

G52CPP C++ Programming Lecture 7. Dr Jason Atkin

G52CPP C++ Programming Lecture 7. Dr Jason Atkin G52CPP C++ Programming Lecture 7 Dr Jason Atkin 1 This lecture classes (and C++ structs) Member functions inline functions 2 Last lecture: predict the sizes 3 #pragma pack(1) #include struct A

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

INTERMEDIATE SOFTWARE DESIGN SPRING 2011 ACCESS SPECIFIER: SOURCE FILE

INTERMEDIATE SOFTWARE DESIGN SPRING 2011 ACCESS SPECIFIER: SOURCE FILE HEADER FILE A header (.h,.hpp,...) file contains Class definitions ( class X {... }; ) Inline function definitions ( inline int get_x() {... } ) Function declarations ( void help(); ) Object declarations

More information

G52CPP C++ Programming Lecture 9

G52CPP C++ Programming Lecture 9 G52CPP C++ Programming Lecture 9 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture const Constants, including pointers The C pre-processor And macros Compiling and linking And

More information

C: How to Program. Week /Apr/23

C: How to Program. Week /Apr/23 C: How to Program Week 9 2007/Apr/23 1 Review of Chapters 1~5 Chapter 1: Basic Concepts on Computer and Programming Chapter 2: printf and scanf (Relational Operators) keywords Chapter 3: if (if else )

More information

Advanced Pointer Topics

Advanced Pointer Topics Advanced Pointer Topics Pointers to Pointers A pointer variable is a variable that takes some memory address as its value. Therefore, you can have another pointer pointing to it. int x; int * px; int **

More information

SYSC 2006 C Winter String Processing in C. D.L. Bailey, Systems and Computer Engineering, Carleton University

SYSC 2006 C Winter String Processing in C. D.L. Bailey, Systems and Computer Engineering, Carleton University SYSC 2006 C Winter 2012 String Processing in C D.L. Bailey, Systems and Computer Engineering, Carleton University References Hanly & Koffman, Chapter 9 Some examples adapted from code in The C Programming

More information

Functions in C C Programming and Software Tools

Functions in C C Programming and Software Tools Functions in C C Programming and Software Tools N.C. State Department of Computer Science Functions in C Functions are also called subroutines or procedures One part of a program calls (or invokes the

More information

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please

More information

CSE 333 Autumn 2013 Midterm

CSE 333 Autumn 2013 Midterm CSE 333 Autumn 2013 Midterm Please do not read beyond this cover page until told to start. A question involving what could be either C or C++ is about C, unless it explicitly states that it is about C++.

More information

Here's how you declare a function that returns a pointer to a character:

Here's how you declare a function that returns a pointer to a character: 23 of 40 3/28/2013 10:35 PM Violets are blue Roses are red C has been around, But it is new to you! ANALYSIS: Lines 32 and 33 in main() prompt the user for the desired sort order. The value entered is

More information

MIDTERM EXAM. CS 217 October 28, Name: Precept: Honor Code: Score: Problem Score Max

MIDTERM EXAM. CS 217 October 28, Name: Precept: Honor Code: Score: Problem Score Max MIDTERM EXAM CS 217 October 28, 1999 Name: Precept: Honor Code: Score: Problem Score Max 1 15 2 5 3 10 4 15 5 5 6 10 7 10 Total 70 1 1. Number Systems (a) Translate the following decimal numbers to binary,

More information

C mini reference. 5 Binary numbers 12

C mini reference. 5 Binary numbers 12 C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char

More information

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems Programs CSCI 4061 Introduction to Operating Systems C Program Structure Libraries and header files Compiling and building programs Executing and debugging Instructor: Abhishek Chandra Assume familiarity

More information

THE UNIVERSITY OF WESTERN ONTARIO. COMPUTER SCIENCE 211a FINAL EXAMINATION 17 DECEMBER HOURS

THE UNIVERSITY OF WESTERN ONTARIO. COMPUTER SCIENCE 211a FINAL EXAMINATION 17 DECEMBER HOURS Computer Science 211a Final Examination 17 December 2002 Page 1 of 17 THE UNIVERSITY OF WESTERN ONTARIO LONDON CANADA COMPUTER SCIENCE 211a FINAL EXAMINATION 17 DECEMBER 2002 3 HOURS NAME: STUDENT NUMBER:

More information

Lecture 3. Review. CS 141 Lecture 3 By Ziad Kobti -Control Structures Examples -Built-in functions. Conditions: Loops: if( ) / else switch

Lecture 3. Review. CS 141 Lecture 3 By Ziad Kobti -Control Structures Examples -Built-in functions. Conditions: Loops: if( ) / else switch Lecture 3 CS 141 Lecture 3 By Ziad Kobti -Control Structures Examples -Built-in functions Review Conditions: if( ) / else switch Loops: for( ) do...while( ) while( )... 1 Examples Display the first 10

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #8 Feb 27 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline More c Preprocessor Bitwise operations Character handling Math/random Review for midterm Reading: k&r ch

More information

Maemo Diablo Reference Manual for maemo 4.1. Application Development

Maemo Diablo Reference Manual for maemo 4.1. Application Development Maemo Diablo Reference Manual for maemo 4.1 Application Development December 22, 2008 Contents 1 Application Development 3 1.1 Introduction.............................. 3 1.2 Typical Maemo GUI Application..................

More information

Personal SE. Functions, Arrays, Strings & Command Line Arguments

Personal SE. Functions, Arrays, Strings & Command Line Arguments Personal SE Functions, Arrays, Strings & Command Line Arguments Functions in C Syntax like Java methods but w/o public, abstract, etc. As in Java, all arguments (well, most arguments) are passed by value.

More information

2 Compiling a C program

2 Compiling a C program 2 Compiling a C program This chapter describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header

More information

of the minimum polling period, the ability to support asynchronous events, a

of the minimum polling period, the ability to support asynchronous events, a A developer s guide to Plasmoids Cosmi, Fotolia Creating Plasmoids We take a peek at how to create your own plasmoids for the latest KDE desktop, giving you the power to build the perfect active desktop

More information

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

Qt in Education. The Qt object model and the signal slot concept Qt in Education The Qt object model and the signal slot concept. 2012 Digia Plc. The enclosed Qt Materials are provided under the Creative Commons Attribution-Share Alike 2.5 License Agreement. The full

More information

C Arrays. Group of consecutive memory locations Same name and type. Array name + position number. Array elements are like normal variables

C Arrays. Group of consecutive memory locations Same name and type. Array name + position number. Array elements are like normal variables 1 6 C Arrays 6.2 Arrays 2 Array Group of consecutive memory locations Same name and type To refer to an element, specify Array name + position number arrayname[ position number ] First element at position

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready.

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready. Name: CSE 303, Winter 2007, Final Examination 15 March 2007 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for two 8.5x11in pieces of paper (both

More information

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types

More information

CSE 333 Lecture 7 - final C details

CSE 333 Lecture 7 - final C details CSE 333 Lecture 7 - final C details Steve Gribble Department of Computer Science & Engineering University of Washington Today s topics: - a few final C details header guards and other preprocessor tricks

More information

INFORMATION SOCIETY TECHNOLOGIES (IST) PROGRAMME. Project IST MoWGLI. Report n. D4.a MathML Rendering/Browsing Engine

INFORMATION SOCIETY TECHNOLOGIES (IST) PROGRAMME. Project IST MoWGLI. Report n. D4.a MathML Rendering/Browsing Engine INFORMATION SOCIETY TECHNOLOGIES (IST) PROGRAMME Project IST-2001-33562 MoWGLI Report n. D4.a MathML Rendering/Browsing Engine Main Authors: H. Naciri, L. Padovani Project Acronym: MoWGLI Project full

More information

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world alun@debian:~$ gcc hello.c alun@debian:~$ a.out Hello, world alun@debian:~$ gcc -o hello hello.c alun@debian:~$ hello Hello, world alun@debian:~$ 1 A Quick guide to C for Networks and Operating Systems

More information

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

More information

Main differences with Java

Main differences with Java Signals, Instruments, and Systems W2 C Programming (continued) C Main differences with Java C is NOT object oriented. (C++ is OO) C code is directly translated into binary that can be directly executed

More information

Gnome pilot conduits. Eskil Olsen Manish Vachharajani JP Rosevear

Gnome pilot conduits. Eskil Olsen Manish Vachharajani JP Rosevear Gnome pilot conduits Eskil Olsen Manish Vachharajani JP Rosevear Gnome pilot conduits by Eskil Olsen, Manish Vachharajani, and JP Rosevear Revision History Revision 1.3.1 20001022 Typo corrections, correct

More information

Integrating QML with C++

Integrating QML with C++ Integrating QML with C++ Qt Essentials - Training Course Produced by Nokia, Qt Development Frameworks Material based on Qt 4.7, created on January 18, 2011 http://qt.nokia.com 1/60 Module: Integrating

More information

CS201 Some Important Definitions

CS201 Some Important Definitions CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

More information

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; }

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; } Modifiers unsigned. For example unsigned int would have a range of [0..2 32 1] on a 32-bit int machine. const Constant or read-only. Same as final in Java. static Similar to static in Java but not the

More information

Luar Topics. C A Low level Programming Language Make A dependency based build system YUYV Representation of Color ZMP Zero Moment Point control

Luar Topics. C A Low level Programming Language Make A dependency based build system YUYV Representation of Color ZMP Zero Moment Point control Luar Topics C A Low level Programming Language Make A dependency based build system YUYV Representation of Color ZMP Zero Moment Point control C A Low level Programming Language Low level Compiles to machine

More information

Lecture 04 FUNCTIONS AND ARRAYS

Lecture 04 FUNCTIONS AND ARRAYS Lecture 04 FUNCTIONS AND ARRAYS 1 Motivations Divide hug tasks to blocks: divide programs up into sets of cooperating functions. Define new functions with function calls and parameter passing. Use functions

More information

Review: Constants. Modules and Interfaces. Modules. Clients, Interfaces, Implementations. Client. Interface. Implementation

Review: Constants. Modules and Interfaces. Modules. Clients, Interfaces, Implementations. Client. Interface. Implementation Review: Constants Modules and s CS 217 C has several ways to define a constant Use #define #define MAX_VALUE 10000 Substitution by preprocessing (will talk about this later) Use const const double x =

More information

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types

More information

CSE 333 Midterm Exam 7/27/15 Sample Solution

CSE 333 Midterm Exam 7/27/15 Sample Solution Question 1. (24 points) C programming. In this problem we want to implement a set of strings in C. A set is represented as a linked list of strings with no duplicate values. The nodes in the list are defined

More information

The C standard library

The C standard library C introduction The C standard library The C standard library 1 / 12 Contents Do not reinvent the wheel Useful headers Man page The C standard library 2 / 12 The Hitchhiker s Guide to the standard library

More information

CS 237 Meeting 18 10/22/12

CS 237 Meeting 18 10/22/12 CS 237 Meeting 18 10/22/12 Announcements 1. Midterm: New date: Oct 29th. In class open book/notes. 2. Duane Bailey has volunteered to do a chips and breadboards lab this week. Will any of you volunteer

More information