DOC PREVIEW
IUPUI CS 265 - Programming with Qt

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Programming with QtOutlineGUI toolkitsSignals and SlotsThe Qt StoryThe Layered X Programming APIsImplementing Cross-Platform GUI Libraries“Dumbing-down” Components“Mapping” Components“Smarting-up” ComponentsA Simple Example /* HelloWorld.cpp */Callback FunctionCallback Function(cont)Event HandlingSlide 15Signals and Slots (cont)Signals and Slots(cont)Slide 18Defining Signals and SlotsEventsWidgetsQt, a GUI toolkitDesigning GUI’sOther Features of QtOther Features of Qt(cont)AcknowledgementsDale RobertsProgramming with QtProgramming with QtDale Roberts, LecturerComputer Science, IUPUIE-mail: [email protected] of Computer and Information Science,School of Science, IUPUIDale RobertsOutlineOutlineThe Qt StoryThe Qt StoryThe Layered X Programming APIsThe Layered X Programming APIsImplementing Cross-Platform GUI LibrariesImplementing Cross-Platform GUI LibrariesA Simple ExampleA Simple ExampleCallback FunctionCallback FunctionSignals and SlotsSignals and SlotsOther Features of QtOther Features of QtDale RobertsGUI toolkitsGUI toolkitsWindows – MFCWindows – MFCMac – MacOSMac – MacOSUnix – many. Most popular: Motif (on which CDE is Unix – many. Most popular: Motif (on which CDE is based). Specifies look and feel. based). Specifies look and feel. (Difficult, error-prone, and not much fun.)(Difficult, error-prone, and not much fun.)QT: portableQT: portable"framework" – also handles sending events to widgets"framework" – also handles sending events to widgetsNot based on layering (too slow, LCD)Not based on layering (too slow, LCD)Not based on API emulation (slow; different platforms require different Not based on API emulation (slow; different platforms require different APIAPIBased on GUI emulation Based on GUI emulationDale RobertsSignals and SlotsSignals and SlotsVarious Various widgetswidgetsPanes – Panes – splittersplitterTables – Tables – tabletableXML parsing – XML parsing – tagreadertagreaderNetworking, sound, printingNetworking, sound, printing2D graphics – 2D graphics – drawlinesdrawlines canvascanvas xformxformOpenGL support – OpenGL support – geargear OpenGL widgets, pixmaps – OpenGL widgets, pixmaps – glpixmapsglpixmapsDale RobertsThe Qt StoryThe Qt StoryThe Qt toolkit is a multi-platform C++ GUI toolkit (class library) that The Qt toolkit is a multi-platform C++ GUI toolkit (class library) that has been developed over a 4 year period. has been developed over a 4 year period. The company Troll Tech AS was founded in 1994 to secure future The company Troll Tech AS was founded in 1994 to secure future development of Qt. development of Qt. Qt for X11 has a non-commercial license which grants any Qt for X11 has a non-commercial license which grants any developer the right to use Qt to develop software for the free developer the right to use Qt to develop software for the free software community.software community.Qt allows the user to choose between the Motif and the Windows Qt allows the user to choose between the Motif and the Windows look and feel.look and feel.Dale RobertsThe Layered X Programming APIsThe Layered X Programming APIsDale RobertsImplementing Cross-Platform GUI LibrariesImplementing Cross-Platform GUI LibrariesThree typical approaches for developing a cross-platform product Three typical approaches for developing a cross-platform product are toare to1. “Dumb-down” the components1. “Dumb-down” the components2. Map the components onto an existing API2. Map the components onto an existing API3. “Smart-up” the components3. “Smart-up” the componentsDale Roberts““Dumbing-down” ComponentsDumbing-down” ComponentsAPI LayeringAPI Layering- e.g. wxWindows- e.g. wxWindows- advantage:- advantage:1. easy to program1. easy to program2. look-and-feel is 100% compatible with the 2. look-and-feel is 100% compatible with the native look-and-feelnative look-and-feel- disadvantage:- disadvantage:1. slower1. slower2. awkward control flow2. awkward control flow3. typically provide the lowest common denominator3. typically provide the lowest common denominator of functionalityof functionality4. difficult to inherit widgets and specialize them4. difficult to inherit widgets and specialize themDale Roberts““Mapping” ComponentsMapping” ComponentsAPI emulationAPI emulation- e.g. MainWin, Wind/U- e.g. MainWin, Wind/U- advantage:- advantage:1. not necessary to emulate original platform1. not necessary to emulate original platform- disadvantage:- disadvantage:1. too different for making API emulation very1. too different for making API emulation very practicalpractical2. emulated platform would be slower2. emulated platform would be slower3. unstable3. unstableDale Roberts““Smarting-up” ComponentsSmarting-up” ComponentsGUI emulationGUI emulation- e.g. Qt- e.g. Qt- advantage:- advantage:1. fastest1. fastest2. changeable style2. changeable style3. easy to inherit widgets and to redefine its3. easy to inherit widgets and to redefine its behaviorbehavior- disadvantage:- disadvantage:1. can’t 100% exact1. can’t 100% exact2. codes has to rewritten if a new widget be created2. codes has to rewritten if a new widget be createdDale RobertsA Simple ExampleA Simple Example/* HelloWorld.cpp *//* HelloWorld.cpp */ 1 #include <qapplication.h>1 #include <qapplication.h> 2 #include <qlabel.h>2 #include <qlabel.h> 33 4 int main(int argc, char **argv) {4 int main(int argc, char **argv) { 55 6 QApplication myapp(argc, argv);6 QApplication myapp(argc, argv); 77 8 Qlabel *mylabel = new Qlabel(“Hello World”);8 Qlabel *mylabel = new Qlabel(“Hello World”); 9 mylabel->resize(100, 200);9 mylabel->resize(100, 200);101011 myapp.setMainWidget(mylabel);11 myapp.setMainWidget(mylabel);1212 mylabel->show(); mylabel->show();1313 return myapp.exec(); return myapp.exec();14 }14 }Dale RobertsCallback FunctionCallback FunctionOne of the most feared and hackish aspects of GUI programming hOne of the most feared and hackish aspects of GUI programming has always been the dreaded callback-function.as always been the dreaded callback-function.A register table for widget (e.g. Motif) A register table for widget (e.g. Motif) - no type checking- no type checking- example:- example: 1. quit = XtVaCreateManagedWidget(……);1. quit = XtVaCreateManagedWidget(……); 2. XtAddCallback(quit, XmNactivateCallback,2. XtAddCallback(quit,


View Full Document

IUPUI CS 265 - Programming with Qt

Download Programming with Qt
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Programming with Qt and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Programming with Qt 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?