Download presentation
Presentation is loading. Please wait.
1
QT Programming Seminar Date : Dec 22, 2001 Time : 9:15AM – 12:15AM Venue : HSB 508, CUHK Speaker : Alex Tsui Dr. Y.S. Moon Sam Cheng K.F. Fong Eric Tang K.C. Chan
2
History Trolltech AS Trolltech AS Founded in 1994 Founded in 1994 Computer software company Computer software company Provide software development tools, libraries and consulting services Provide software development tools, libraries and consulting services First commercial Qt - 1995 First commercial Qt - 1995
3
What is Qt C++ toolkits for application development C++ toolkits for application development Target all major OS with a single application source code Target all major OS with a single application source code Provide platform-independent API Provide platform-independent API Native C APIs are encapsulated with object-oriented C++ classes Native C APIs are encapsulated with object-oriented C++ classes
4
Advantage of Qt Can maintain same set of source code for multi-platform Can maintain same set of source code for multi-platform Fast productivities on different platform Fast productivities on different platform Easy to maintain application source code Easy to maintain application source code Provide native look and feel for different platform Provide native look and feel for different platform
5
Qt/Desktop Qt/Windows for MS Windows Qt/Windows for MS Windows Qt/X11 for Linux, Solaris, HP-UX, Irix, AIX Qt/X11 for Linux, Solaris, HP-UX, Irix, AIX Qt/Mac Apple Mac OS X Qt/Mac Apple Mac OS X
6
Qt/Embedded Designed for embedded device with limited resources Designed for embedded device with limited resources Provide full GUI functionality without X11 Provide full GUI functionality without X11 Reduce memory and CPU demand Reduce memory and CPU demand Can be scaled down for dedicated system Can be scaled down for dedicated system Fully compatible with Qt/Desktop Fully compatible with Qt/Desktop
7
What is QPE/Qtopia Window environment designed for PDAs Window environment designed for PDAs Based on libraries under Qt/Embedded Based on libraries under Qt/Embedded Provide Personal Information Management applications Provide Personal Information Management applications Calendar, address book..etc Calendar, address book..etc Web browser and Java support with third party development Web browser and Java support with third party development
8
QPE Desktop Simulation (1) Method 1 – X11 simulation Method 1 – X11 simulation Simulate QPE in X11 environment Simulate QPE in X11 environment Advantage Advantage Easy to control as we familiar to X11 environment Easy to control as we familiar to X11 environment Display card no need to have framebuffer support Display card no need to have framebuffer support Disadvantage Disadvantage Simulation may be inaccurate compare to the final result in embedded device Simulation may be inaccurate compare to the final result in embedded device Fonts may not be displayed correctly in embedded device as simulation use font library provided from X11 Fonts may not be displayed correctly in embedded device as simulation use font library provided from X11
9
QPE Desktop Simulation (2) Method 2 – framebuffer simulation Method 2 – framebuffer simulation Directly use frambuffer device for simulation Directly use frambuffer device for simulation Advantage Advantage Can provide a accurate simulation compare to X11 Can provide a accurate simulation compare to X11 Disadvantage Disadvantage Display card must support framebuffer Display card must support framebuffer Keyboard and mouse devices may crash when return from framebuffer simulation Keyboard and mouse devices may crash when return from framebuffer simulation Need to restart keyboard/mouse drivers Need to restart keyboard/mouse drivers
10
Framebuffer simulation Requirements Requirements PC with Linux OS (We use 7.1 here) PC with Linux OS (We use 7.1 here) Video card with framebuffer support (usually only very old video card do not support it) Video card with framebuffer support (usually only very old video card do not support it) Tools needed Tools needed Qt/X11 Qt/X11 Qt/Embedded Qt/Embedded QPE/Qtopia QPE/Qtopia tmake tmake
11
Tools for simulation Qt/X11 Qt/X11 Provide uic - user interface converter Provide uic - user interface converter UIC is used to convert Qt designer files to.cpp and.h files UIC is used to convert Qt designer files to.cpp and.h files Designer files are generated from designer tools in Qt for designing the interface visually Designer files are generated from designer tools in Qt for designing the interface visually Qt/Embedded need “uic” for compiling the gui libraries Qt/Embedded need “uic” for compiling the gui libraries Qt/Embedded Qt/Embedded Provide Qt libraries for embedded devices Provide Qt libraries for embedded devices QPE/Qtopia QPE/Qtopia Provide a complete window manager with icons, input methods and resource management Provide a complete window manager with icons, input methods and resource management
12
Tools for add applications tmake tmake A cross-platform Makefile Tool A cross-platform Makefile Tool For creating and maintaining makefiles for software project For creating and maintaining makefiles for software project
13
Demos QPE Desktop Simulation QPE Desktop Simulation Add applications to QPE Add applications to QPE QPE on embedded device - Assabet QPE on embedded device - Assabet
14
Qt Designer A visual form designer for Qt provided in Qt/x11 A visual form designer for Qt provided in Qt/x11 Simple implementation and design of user interfaces Simple implementation and design of user interfaces Allow to add actions and widgets (such as button or tool bar) on the form visually Allow to add actions and widgets (such as button or tool bar) on the form visually
15
Qt Designer Steps in creating a form with Qt Designer and uic 1. Start the designer in Qt/X11 2. Add the necessary widgets in a form using the designer 3. It will create a.ui file 4. Run uic to convert the.ui file to a.h file and.cpp file (implementation files) 5. Create main.cpp to instantiate the QApplication object and start the event loop
16
Qt Designer Add widgets in a form form.ui uic form.h form.cpp main.cpp #include read & write
17
Demo Demonstration on using Qt Designer and uic Demonstration on using Qt Designer and uic Online Reference: Online Reference:http://doc.trolltech.com/3.0/designer-manual-8.html
18
Text Processing Qt 2.0 and later versions have full support for Unicode 16-bit international character set Qt 2.0 and later versions have full support for Unicode 16-bit international character set It uses Unicode for text processing and string storage It uses Unicode for text processing and string storage Qt provides different text codec classes Qt provides different text codec classes It can display texts with different encodings such as Big5 or GB It can display texts with different encodings such as Big5 or GB
19
Display Chinese in Qt Steps in displaying Chinese text in Qt 1. Create a text codec (Big5Codec or GBKCodec) 2. Use the decoder to convert the Chinese text to Unicode 3. Use “ unifont ” to display the string
20
Display Chinese in Qt (Example) QCString big5Str = “ 歡迎光臨 ”; // Chinese String // Create big5 codec QTextCodec *big5Codec = QTextCodec::codecForName(“Big5”); QTextCodec *big5Codec = QTextCodec::codecForName(“Big5”); QTextDecoder *big5Decoder = big5Codec- >makeDecoder(); // Convert Chinese text to Unicode format QString big5UnicodeStr = big5Decoder- >toUnicode(big5Str.data(), big5Str.length()); QString big5UnicodeStr = big5Decoder- >toUnicode(big5Str.data(), big5Str.length()); // Set display font QFont unifont(“unifont”, 16, 50); unifont.setPixelSize(16);
21
Font Formats in Qt TrueType (TTF) TrueType (TTF) the scalable font technology on MS-Windows and Apple Macintosh the scalable font technology on MS-Windows and Apple Macintosh Postscript Type1 (PFA/PFB) Postscript Type1 (PFA/PFB) scalable fonts often used by printers, also popular on X11 scalable fonts often used by printers, also popular on X11 Bitmap Distribution Format fonts (BDF) Bitmap Distribution Format fonts (BDF) a standard format for non-scalable fonts a standard format for non-scalable fonts Qt Prerendered Font (QPF) Qt Prerendered Font (QPF) a light-weight non-scalable font format specific to Qt/Embedded a light-weight non-scalable font format specific to Qt/Embedded
22
Demos A text editor which can load and display different languages A text editor which can load and display different languages
23
Browsers in Qt/Embedded There are 3 possible choices: There are 3 possible choices: Qt Mozilla (www.mozilla.org) Qt Mozilla (www.mozilla.org) Opera (www.opera.org) Opera (www.opera.org) Konqueror/Embedded – with better support and easy to compile it (www.konqueror.org/embedded.html) Konqueror/Embedded – with better support and easy to compile it (www.konqueror.org/embedded.html)
24
Konqueror/Embedded A special version of the KDE browser A special version of the KDE browser It can run on the Qt/Embedded platform for embedded devices It can run on the Qt/Embedded platform for embedded devices Small and do not require X-window system Small and do not require X-window system Support HTML4, CSS, SSL, Javascript, Cookies and IPv6 Support HTML4, CSS, SSL, Javascript, Cookies and IPv6 Can be scaled down during configuration (disable SSL) Can be scaled down during configuration (disable SSL)
25
Konqueror/Embedded It can display web pages of different character sets such as Big5 or Utf-8 It can display web pages of different character sets such as Big5 or Utf-8 Tricks in making Konq/E display pages with different languages: Tricks in making Konq/E display pages with different languages: Compile the Qt/Embedded library with different encoding support Compile the Qt/Embedded library with different encoding support Use “ unifont ” font to display the web pages Use “ unifont ” font to display the web pages
26
Demo Compilation and configuration of the Konq/E with Qt/Embedded and QPE support Compilation and configuration of the Konq/E with Qt/Embedded and QPE support
27
Built-in input method in QPE Built-in input method in QPE Handwriting Handwriting Keyboard Keyboard Pickboard Pickboard Unicode Unicode Input Method
28
Chinese Input Method Based on the keyboard implementation, which provides all the event handlings Based on the keyboard implementation, which provides all the event handlings Add the English string to Chinese character mapping Add the English string to Chinese character mapping e.g. onf -> 你 (0xa741) Match the input English string to the corresponding Chinese character Match the input English string to the corresponding Chinese character Convert the Chinese Char to Unicode format Convert the Chinese Char to Unicode format
29
Demo Inputting Big5 characters using ChangJie in QPE Inputting Big5 characters using ChangJie in QPE
30
Linux Device Driver From 2.0 to 2.4 Kernel
31
Linux Device Driver Overview (Simplified Version) User Applications KERNEL APIs e.g. File Systems/Memory System Linux KERNEL System calls Linux Kernel Modules e.g. Linux device drivers Hardware Devices e.g. CPU/Memory/IO ports.
32
Linux Device Driver Two most common types: Two most common types: Character Device (e.g. printer) Character Device (e.g. printer) Block Device (e.g. hard disk) Block Device (e.g. hard disk) The differences: The differences: Block Device Block Device Buffer for each block in this device Buffer for each block in this device Fast read/write of blocks. Fast read/write of blocks. Character Device Character Device Sequence of bytes Sequence of bytes
33
Implement simple character device driver Module architecture: Module architecture: Init_module() Init_module() Initialize this kernel module Initialize this kernel module Register this module to the kernel Register this module to the kernel Exit_module() Exit_module() Cleanup all the memories. Cleanup all the memories. Unregister it. Unregister it. From 2.0 to 2.4 From 2.0 to 2.4 Provide module_init() & module_exit() to specify the init/exit functions Provide module_init() & module_exit() to specify the init/exit functions
34
Implement file Operations Provide implementations for the user to access this device. Provide implementations for the user to access this device. E.g. read/write/ioctl. E.g. read/write/ioctl. Register it to the kernel. Register it to the kernel. 2.4 kernel changed the file operations/ inode operations. 2.4 kernel changed the file operations/ inode operations.
35
File Operations 2.4 File operations : File operations : Owner /* new */ Owner /* new */ lseek lseek read read write write readdir readdir poll poll ioctl ioctl mmap mmap open open flush flush release release fsync fsync fasync fasync lock lock Readv /* new */ Readv /* new */ Writev /* new */ Writev /* new */
36
Port from 2.0 to 2.4 use gcc labeled elements extension for initialize the fops use gcc labeled elements extension for initialize the fops E.g. E.g. struct file_operations{ read: device_read, write: device_write, open: device_open, release: device_close } Avoid ordering problems of the elements in fops. Avoid ordering problems of the elements in fops.
37
Infineon FingerTIP Driver In Desktop, we can use inb(), outb to read/write parallel port (EPP mode) In Desktop, we can use inb(), outb to read/write parallel port (EPP mode) In Embedded Linux, we can use internal register ( directly access I/O pins ), software simulated EPP mode. In Embedded Linux, we can use internal register ( directly access I/O pins ), software simulated EPP mode.
38
Thank You!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.