QT高级编程.pdf
《QT高级编程.pdf》由会员分享,可在线阅读,更多相关《QT高级编程.pdf(554页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Advanced Qt Programming This page intentionally left blank Advanced Qt ProgrammingCreating Great Software with C+and Qt 4Mark SummerfieldUpper Saddle River,NJBostonIndianapolisSanFranciscop New YorkTorontoMontrealLondonMunichParisMadridpCapetownSydneyTokyoSingaporeMexico City Many of the designation
2、s used by manufacturers and sellers to distinguish their products are claimed as trademarks.Where those designations appear in this book,and the publisher was aware of a trademark claim,the designations have been printed with initial capital letters or in all capitals.The author and publisher have t
3、aken care in the preparation of this book,but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions.No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained h
4、erein.The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales,which may include electronic versions and/or custom covers and content particular to your business,training goals,marketing focus,and branding interests.For more information,pleas
5、e contact:U.S.Corporate and Government Sales (800)382-3419 For sales outside the United States,please contact:International Sales Visit us on the Web: of Congress Cataloging-in-Publication DataSummerfield,Mark.Advanced Qt programming:creating great software with C+and Qt 4/Mark Summerfield.p.mcm.Inc
6、ludes bibliographical references and index.ISBN 978-0-321-63590-7(hardcover:alk.paper)1.Qt(Electronic resource)2.Graphical user interfaces(Computer systems)3.C+(Computer program language)I.Title.QA76.9.U83S88 2010 005.113dc222010019289Copyright 2011 Qtrac Ltd.All rights reserved.Printed in the Unite
7、d States of America.This publication is protected by copyright,and permission must be obtained from the publisher prior to any prohibited reproduction,storage in a retrieval system,or transmission in any form or by any means,electronic,mechanical,photocopying,recording,or likewise.For information re
8、garding permissions,write to:Pearson Education,Inc.Rights and Contracts Department 501 Boylston Street,Suite 900 Boston,MA 02116 Fax:(617)671-3447ISBN-13:978-0-321-63590-7ISBN-10:0-321-63590-6Text printed in the United States on recycled paper at Courier in Westford,Massachusetts.First printing,July
9、 2010 This book is dedicated toAnna RebeccaPaterson This page intentionally left blank Contents at a GlanceList of Tables.xiiiForeword.xvIntroduction.1Chapter 1.Hybrid Desktop/Internet Applications.5Chapter 2.Audio and Video.53Chapter 3.Model/View Table Models.87Chapter 4.Model/View Tree Models.129C
10、hapter 5.Model/View Delegates.185Chapter 6.Model/View Views.207Chapter 7.Threading with QtConcurrent.245Chapter 8.Threading with QThread.287Chapter 9.Creating Rich Text Editors.317Chapter 10.Creating Rich Text Documents.359Chapter 11.Creating Graphics/View Windows.389Chapter 12.Creating Graphics/Vie
11、w Scenes.409Chapter 13.The Animation and State Machine Frameworks.469Epilogue.491Selected Bibliography.495Index.499www.qtrac.eu/aqpbook.htmlvii This page intentionally left blank ContentsList of Tables.xiiiForeword.xvIntroduction.1Acknowledgements.3Chapter 1.Hybrid Desktop/Internet Applications.5Int
12、ernet-Aware Widgets.6Using WebKit.21A Generic Web Browser Window Component.22Creating Web Site-Specific Applications.30Embedding Qt Widgets in Web Pages.44Chapter 2.Audio and Video.53Using QSound and QMovie.54The Phonon MultimediaFramework.60Playing Music.64Playing Videos.80Chapter 3.Model/View Tabl
13、e Models.87Qts Model/View Architecture.88Using QStandardItemModels for Tables.90Changing a Table Model through the User Interface.91A QStandardItemModelSubclass for Tables.102A QSortFilterProxyModelto Filter Out Duplicate Rows.107A QSortFilterProxyModel to Filter In Wanted Rows.109Creating CustomTab
14、le Models.113Changing a Table Model through the User Interface.113A CustomQAbstractTableModelSubclass for Tables.116The QAbstractItemModelAPIMethods for Tables.117Methods to Support Saving and Loading Table Items.126ix Chapter 4.Model/View Tree Models.129Using QStandardItemModels for Trees.130Changi
15、ng a Tree Model through the User Interface.131A QStandardItemSubclass for Tree Items.141A QStandardItemModelSubclass for Trees.143Creating CustomTree Models.151Changing a Tree Model through the User Interface.152A CustomItem Class for Tree Items.155A CustomQAbstractItemModelSubclass for Trees.158The
16、 QAbstractItemModelAPIfor Trees.160The QAbstractItemModelAPIfor Drag and Drop.168Methods for Saving and Loading Tree Items.180Chapter 5.Model/View Delegates.185Datatype-Specific Editors.186Datatype-Specific Delegates.188A ReadOnly Column or Row Delegate.188An Editable Column or Row Delegate.193Model
17、-Specific Delegates.201Chapter 6.Model/View Views.207QAbstractItemView Subclasses.208Model-Specific Visualizing Views.224The Visualizer Widget.225The Visualizers AggregatedHeader Widget.232The Visualizers AggregatedView Widget.235Chapter 7.Threading with QtConcurrent.245Executing Functions in Thread
18、s.248Using QtConcurrent:run().252Using QRunnable.257Filtering and Mapping in Threads.261Using QtConcurrent to Filter.270Using QtConcurrent to Filter and Reduce.277Using QtConcurrent to Map.281Chapter 8.Threading with QThread.Processing Independent Items.287Processing Shared Items.302x Chapter 9.Crea
19、ting Rich Text Editors.317Introducing QTextDocument.318CreatingCustomText Editors.320Completion for Line Edits and Comboboxes.320Completion and Syntax Highlightingfor Text Editors.322Completion for Multi-line Editors.323Syntax Highlighting.336A Rich Text Single Line Editor.342Multi-line Rich Text Ed
20、iting.353Chapter 10.Creating Rich Text Documents.359Exported QTextDocument File Quality.361Creating QTextDocuments.364Creating QTextDocuments with HTML.364Creating QTextDocuments with QTextCursor.367Exporting and Printing Documents.371Exporting QTextDocuments.372Exporting in PDF and PostScript Forma
21、t.372Exporting in Open Document Format.373Exporting in HTML Format.374Exporting in SVG Format.375Exporting in Pixmap Formats.375Printing and Previewing QTextDocuments.376Painting Pages.379Painting PDF or PostScript.387Painting SVG.387Painting Pixmaps.388Chapter 11.Creating Graphics/View Windows.389T
22、he Graphics/View Architecture.390Graphics/View Widgets and Layouts.392Introducing Graphics Items.399Chapter 12.Creating Graphics/View Scenes.409Scenes,Items,and Actions.411Creating the Main Window.412Saving,Loading,Printing,and Exporting Scenes.415Saving Scenes.415Loading Scenes.417xi Printing and E
23、xporting Scenes.420ManipulatingGraphics Items.423Adding Items.425Copying,Cutting,and Pasting Items.427ManipulatingSelected Items.430Showing and Hiding the Guideline Grid.435Keeping the User Interface Up to Date.436Enhancing QGraphicsView.439Creatinga Dock Widget Toolbox.440Creating CustomGraphics It
24、ems.447Enhancing QGraphicsTextItem.447Graphics Item Transformations.453Enhancing an Existing Graphics Item.455Creating a CustomGraphics Item from Scratch.459Chapter 13.The Animation and State Machine Frameworks.469Introducing the Animation Framework.469Introducing the State Machine Framework.474Comb
25、ining Animations and State Machines.481Epilogue.491Selected Bibliography.495Index.499xii List of Tables1.1.The Main WebKit Classes.211.2.Qts Global Utility Functions.462.1.The Main Phonon Classes.633.1.The QAbstractItemModelAPI.1183.2.The Qt:ItemDataRole enum.1193.3.The Qt:ItemFlagenum.1194.1.The QA
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- QT 高级 编程
限制150内