Skip to content

Commit 7de2fd8

Browse files
committed
QThread
1 parent dcffc07 commit 7de2fd8

11 files changed

+38
-30
lines changed

.settings/org.eclipse.core.resources.prefs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ encoding//QTableView/CopyContent/CopyContent.py=utf-8
88
encoding//QTableView/CopyContent/__main__.py=utf-8
99
encoding//QTableWidget/SqlQuery/SqlQuery.py=utf-8
1010
encoding//QTableWidget/SqlQuery/__main__.py=utf-8
11+
encoding//QThread/moveToThread.py=utf-8
12+
encoding//QThread/\u7EBF\u7A0B\u4F11\u7720\u5524\u9192.py=utf-8
13+
encoding//QThread/\u7EBF\u7A0B\u6302\u8D77\u6062\u590D.py=utf-8
14+
encoding//QThread/\u7EE7\u627FQThread.py=utf-8
1115
encoding//QTreeWidget/ParsingJson.py=utf-8
1216
encoding//\u5176\u5B83/C\u548CC++\u6269\u5C55/py\u8F6Cpyd/pydmod.py=utf-8
1317
encoding//\u5176\u5B83/QRC\u8D44\u6E90\u6587\u4EF6\u4F7F\u7528/qrctest1.py=utf-8
@@ -56,10 +60,6 @@ encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248
5660
encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248\u672C1/testNinePatch.py=utf-8
5761
encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248\u672C2/QtNinePatch.py=utf-8
5862
encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248\u672C2/testQtNinePatch.py=utf-8
59-
encoding//\u591A\u7EBF\u7A0B/moveToThread.py=utf-8
60-
encoding//\u591A\u7EBF\u7A0B/\u7EBF\u7A0B\u4F11\u7720\u5524\u9192.py=utf-8
61-
encoding//\u591A\u7EBF\u7A0B/\u7EBF\u7A0B\u6302\u8D77\u6062\u590D.py=utf-8
62-
encoding//\u591A\u7EBF\u7A0B/\u7EE7\u627FQThread.py=utf-8
6363
encoding//\u591A\u9875\u9762/QScrollArea/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/SettingUi.py=utf-8
6464
encoding//\u591A\u9875\u9762/QScrollArea/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F.py=utf-8
6565
encoding//\u591A\u9875\u9762/QStackedWidget/\u5DE6\u4FA7\u9009\u9879\u5361/\u5DE6\u4FA7\u9009\u9879\u5361.py=utf-8

多线程/继承QThread.py renamed to QThread/InheritQThread.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@author: Irony
77
@site: https://pyqt5.com, https://github.com/892768447
88
9-
@file: inheritQThread
9+
@file: InheritQThread
1010
@description: 继承QThread
1111
"""
1212
from PyQt5.QtCore import QThread, pyqtSignal

QThread/README.en.md

Whitespace-only changes.

QThread/README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# QThread
2+
3+
PyQt多线程的简单使用例子
4+
5+
## 1、继承QThread
6+
[运行 InheritQThread.py](InheritQThread.py)
7+
8+
![InheritQThread](ScreenShot/InheritQThread.png)
9+
10+
## 2、moveToThread
11+
[运行 moveToThread.py](moveToThread.py)
12+
13+
![moveToThread](ScreenShot/InheritQThread.png)
14+
15+
## 3、线程挂起恢复
16+
[运行 SuspendThread.py](SuspendThread.py)
17+
18+
注意,这里只是简单演示,在应用这些代码时要小心
19+
20+
1. 这里使用windows的api实现,主要用到`SuspendThread``ResumeThread`函数
21+
1. 利用`ctypes.windll.kernel32.OpenThread(win32con.PROCESS_ALL_ACCESS, False, int(QThread.currentThreadId()))`
22+
1. 得到线程的句柄,然后就可以通过上面的两个函数对其进行挂起与恢复
23+
24+
`ctypes.windll.kernel32.TerminateThread`终止线程,不推荐
25+
26+
![SuspendThread](ScreenShot/SuspendThread.gif)
27+
28+
## 4、线程休眠唤醒
29+
[运行 WakeupThread.py](WakeupThread.py)
30+
31+
使用 `QWaitCondition``wait``wakeAll` 方法
32+
33+
![WakeupThread](ScreenShot/WakeupThread.gif)

QThread/ScreenShot/InheritQThread.png

1.81 KB
Loading
File renamed without changes.
File renamed without changes.
File renamed without changes.

多线程/README.md

-25
This file was deleted.

0 commit comments

Comments
 (0)