qt5 thread

1.qt5 thread

好文章

“How to use QThread in the right way (Part 1)”
http://blog.debao.me/2013/08/how-to-use-qthread-in-the-right-way-part-1/

“How to use QThread in the right way (Part 2)”
http://blog.debao.me/2013/08/how-to-use-qthread-in-the-right-way-part-2/

https://doc.qt.io/qt-5/qcoreapplication.html#postEvent
https://doc.qt.io/qt-5/signalsandslots.html#signals

http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
http://woboq.com/blog/qthread-you-were-not-doing-so-wrong.html
http://ilearnstuff.blogspot.com/2012/08/when-qthread-isnt-thread.html

good

http://blog.debao.me/2013/08/how-to-use-qthread-in-the-right-way-part-1/

https://doc.qt.io/qt-5/qthread.html

https://doc.qt.io/qt-5/qtcore-threads-mandelbrot-example.html

https://doc.qt.io/qt-5/thread-basics.html

https://doc.qt.io/qt-5/thread-basics.html

https://doc-snapshots.qt.io/qt5-5.9/threads-qobject.html

Effective Threading Using Qt
https://nachtimwald.com/2015/05/02/effective-threading-using-qt/

https://doc.qt.io/archives/qq/qq27-responsive-guis.html

https://doc.qt.io/qt-5/examples-threadandconcurrent.html

https://doc.qt.io/qt-5/threads.html

https://wiki.qt.io/Category:Tutorial

Qt::AutoConnection
Qt::DirectConnection
Qt::QueuedConnection
Qt::BlockingQueuedConnection
Qt::UniqueConnection

Qt有一个术语Thread Affinity:
QObject的实例具有线程亲和力,意思是该object接收到queue signal和posted event会运行在该object所在线程。

A QThread object manages one thread of control within the program.
QThreads begin executing in run().
By default, run() starts the event loop by calling exec() and runs a Qt event loop inside the thread.

You can use worker objects by moving them to the thread using QObject::moveToThread().

参考书籍

http://www.qtrac.eu/aqpbook.html

Advanced Qt Programming
Creating Great Software with C++/Qt 4
by Mark Summerfield

这是一本好书!

编译运行项目注意事项:

书中的源代码下载,下载后使用qt creator 5.0.2打开项目文件,比如weathertrayicon.pro,

编辑文件weathertrayicon.pro,在第二行增加widgets。

QT += widgets network xml

如果不增加者一行,编译报错,比如

‘QAbstractButton’ file not found

‘QApplication’ file not found

本书中文译名暂定为:

Advanced Qt Programming: Creating Great Software with C++ and Qt 4

高级Qt编程:用C++和Qt 4创建完美软件

The Thread Support in Qt document is a good starting point into the reference documentation.
Qt comes with several additional examples for QThread and QtConcurrent.
Several good books describe how to work with Qt threads. The most extensive coverage can be found in Advanced Qt Programming by Mark Summerfield, Prentice Hall - roughly 70 of 500 pages cover QThread and QtConcurrent.

11

Chapter 1: Hybrid Desktop/Internet Applications
weathertrayicon
rsspanel
browserwindow
nyrbviewer
matrixquiz
Chapter 2: Audio and Video
moviejingle
playmusic
playvideo
Chapter 3: Model/View Table Models
zipcodes1
zipcodes2
Chapter 4: Model/View Tree Models
timelog1
timelog2
Chapter 5: Model/View Delegates
folderview
timelog1
zipcodes1
Chapter 6: Model/View Views
censusvisualizer
tiledlistview
Chapter 7: Threading with QtConcurrent
image2image
numbergrid
Chapter 8: Threading with QThread
crossfader
findduplicates
Chapter 9: Creating Rich Text Editors
findduplicates
xmledit
timelog1
textedit
Chapter 10: Creating Rich Text Documents
outputsampler
Chapter 11: Creating Graphics/View Windows
petridish1
Chapter 12: Creating Graphics/View Scenes
pagedesigner1
Chapter 13: The Animation and State Machine Frameworks
finddialog
petridish2
pagedesigner2

111

http://www.qtrac.eu/aqpbook.html

Table of Contents
Foreword by Eirik Chambe-Eng
Introduction
Chapter 1. Hybrid Desktop/Internet Applications
Internet-Aware Widgets
Using WebKit
Chapter 2. Audio and Video
Using QSound and QMovie
The Phonon Multimedia Framework
Chapter 3. Model/View Table Models
Qt’s Model/View Architecture
Using QStandardItemModels for Tables
Creating Custom Table Models
Chapter 4. Model/View Tree Models
Using QStandardItemModels for Trees
Creating Custom Tree Models
Chapter 5. Model/View Delegates
Datatype-Specific Editors
Datatype-Specific Delegates
Model-Specific Delegates
Chapter 6. Model/View Views—This is available as a sample chapter—click “Sample Content” and then “Download the sample pages”.
QAbstractItemView Subclasses
Model-Specific Visualizing Views
Chapter 7. Threading with QtConcurrent
Executing Functions in Threads
Filtering and Mapping in Threads
Chapter 8. Threading with QThread
Processing Independent Items
Processing Shared Items
Chapter 9. Creating Rich Text Editors
Introducing QTextDocument
Creating Custom Text Editors
A Rich Text Single Line Editor
Multiline Rich Text Editing
Chapter 10. Creating Rich Text Documents
Exported QTextDocument File Quality
Creating QTextDocuments
Exporting and Printing Documents
Painting Pages
Chapter 11. Creating Graphics/View Windows
The Graphics/View Architecture
Graphics/View Widgets and Layouts
Introducing Graphics Items
Chapter 12. Creating Graphics/View Scenes
Scenes, Items, and Actions
Enhancing QGraphicsView
Creating a Dock Widget Toolbox
Creating Custom Graphics Items
Chapter 13. The Animation and State Machine Frameworks
Introducing the Animation Framework
Introducing the State Machine Framework
Combining Animations and State Machines
Epilogue
Selected Bibliography
Index

参考书籍2

Hands-On High Performance Programming with Qt 5: Build cross-platform applications using concurrency, parallel programming, and memory management

Hands-On High Performance Programming with Qt 5: Build cross-platform applications using concurrency, parallel programming, and memory management

1: UNDERSTANDING PERFORMANT PROGRAMS
2: PROFILING TO FIND BOTTLENECKS
3: DEEP DIVE INTO C++ AND PERFORMANCE
4: USING DATA STRUCTURES AND ALGORITHMS EFFICIENTLY
5: AN IN-DEPTH GUIDE TO CONCURRENCY AND MULTITHREADING
6: PERFORMANCE FAILURES AND HOW TO OVERCOME THEM
7: UNDERSTANDING I/O PERFORMANCE AND OVERCOMING RELATED PROBLEMS
8: OPTIMIZING GRAPHICAL PERFORMANCE
9: OPTIMIZING NETWORK PERFORMANCE
10: QT PERFORMANCE ON EMBEDDED AND MOBILE PLATFORMS
11: TESTING AND DEPLOYING QT APPLICATIONS
What You Will Learn
Understand classic performance best practices
Get to grips with modern hardware architecture and its performance impact
Implement tools and procedures used in performance optimization
Grasp Qt-specific work techniques for graphical user interface (GUI) and platform programming
Make Transmission Control Protocol (TCP) and Hypertext Transfer Protocol (HTTP) performant and use the relevant Qt classes
Discover the improvements Qt 5.9 (and the upcoming versions) holds in store
Explore Qt’s graphic engine architecture, strengths, and weaknesses
Authors
Marek Krajewski
Marek has been programming C++ since the mid-90-ties and Qt since 2008. He was involved with Unix and Windows system programming, client-server systems, UMTS network management, enterprise Java, satellite protocol decoding, neural networks, image processing, DVB-T testing appliances, REST APIs and embedded Linux. He holds a Ph.D. in computer science and is currently working as an independent programmer specializing in system programming, communication protocols, GUIs, C++, and Qt. His other interests are off-piste skiing and aikido.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值