QThread
This commit is contained in:
parent
dcffc073c0
commit
7de2fd8370
11 changed files with 38 additions and 30 deletions
|
@ -8,6 +8,10 @@ encoding//QTableView/CopyContent/CopyContent.py=utf-8
|
||||||
encoding//QTableView/CopyContent/__main__.py=utf-8
|
encoding//QTableView/CopyContent/__main__.py=utf-8
|
||||||
encoding//QTableWidget/SqlQuery/SqlQuery.py=utf-8
|
encoding//QTableWidget/SqlQuery/SqlQuery.py=utf-8
|
||||||
encoding//QTableWidget/SqlQuery/__main__.py=utf-8
|
encoding//QTableWidget/SqlQuery/__main__.py=utf-8
|
||||||
|
encoding//QThread/moveToThread.py=utf-8
|
||||||
|
encoding//QThread/\u7EBF\u7A0B\u4F11\u7720\u5524\u9192.py=utf-8
|
||||||
|
encoding//QThread/\u7EBF\u7A0B\u6302\u8D77\u6062\u590D.py=utf-8
|
||||||
|
encoding//QThread/\u7EE7\u627FQThread.py=utf-8
|
||||||
encoding//QTreeWidget/ParsingJson.py=utf-8
|
encoding//QTreeWidget/ParsingJson.py=utf-8
|
||||||
encoding//\u5176\u5B83/C\u548CC++\u6269\u5C55/py\u8F6Cpyd/pydmod.py=utf-8
|
encoding//\u5176\u5B83/C\u548CC++\u6269\u5C55/py\u8F6Cpyd/pydmod.py=utf-8
|
||||||
encoding//\u5176\u5B83/QRC\u8D44\u6E90\u6587\u4EF6\u4F7F\u7528/qrctest1.py=utf-8
|
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
|
||||||
encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248\u672C1/testNinePatch.py=utf-8
|
encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248\u672C1/testNinePatch.py=utf-8
|
||||||
encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248\u672C2/QtNinePatch.py=utf-8
|
encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248\u672C2/QtNinePatch.py=utf-8
|
||||||
encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248\u672C2/testQtNinePatch.py=utf-8
|
encoding//\u56FE\u7247/\u663E\u793A.9\u683C\u5F0F\u56FE\u7247/\u7EAFpython\u7248\u672C2/testQtNinePatch.py=utf-8
|
||||||
encoding//\u591A\u7EBF\u7A0B/moveToThread.py=utf-8
|
|
||||||
encoding//\u591A\u7EBF\u7A0B/\u7EBF\u7A0B\u4F11\u7720\u5524\u9192.py=utf-8
|
|
||||||
encoding//\u591A\u7EBF\u7A0B/\u7EBF\u7A0B\u6302\u8D77\u6062\u590D.py=utf-8
|
|
||||||
encoding//\u591A\u7EBF\u7A0B/\u7EE7\u627FQThread.py=utf-8
|
|
||||||
encoding//\u591A\u9875\u9762/QScrollArea/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/SettingUi.py=utf-8
|
encoding//\u591A\u9875\u9762/QScrollArea/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/SettingUi.py=utf-8
|
||||||
encoding//\u591A\u9875\u9762/QScrollArea/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F.py=utf-8
|
encoding//\u591A\u9875\u9762/QScrollArea/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/\u4EFFQQ\u8BBE\u7F6E\u9762\u677F.py=utf-8
|
||||||
encoding//\u591A\u9875\u9762/QStackedWidget/\u5DE6\u4FA7\u9009\u9879\u5361/\u5DE6\u4FA7\u9009\u9879\u5361.py=utf-8
|
encoding//\u591A\u9875\u9762/QStackedWidget/\u5DE6\u4FA7\u9009\u9879\u5361/\u5DE6\u4FA7\u9009\u9879\u5361.py=utf-8
|
||||||
|
|
|
@ -6,7 +6,7 @@ Created on 2018年3月9日
|
||||||
@author: Irony
|
@author: Irony
|
||||||
@site: https://pyqt5.com, https://github.com/892768447
|
@site: https://pyqt5.com, https://github.com/892768447
|
||||||
@email: 892768447@qq.com
|
@email: 892768447@qq.com
|
||||||
@file: inheritQThread
|
@file: InheritQThread
|
||||||
@description: 继承QThread
|
@description: 继承QThread
|
||||||
"""
|
"""
|
||||||
from PyQt5.QtCore import QThread, pyqtSignal
|
from PyQt5.QtCore import QThread, pyqtSignal
|
0
QThread/README.en.md
Normal file
0
QThread/README.en.md
Normal file
33
QThread/README.md
Normal file
33
QThread/README.md
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# QThread
|
||||||
|
|
||||||
|
PyQt多线程的简单使用例子
|
||||||
|
|
||||||
|
## 1、继承QThread
|
||||||
|
[运行 InheritQThread.py](InheritQThread.py)
|
||||||
|
|
||||||
|
![InheritQThread](ScreenShot/InheritQThread.png)
|
||||||
|
|
||||||
|
## 2、moveToThread
|
||||||
|
[运行 moveToThread.py](moveToThread.py)
|
||||||
|
|
||||||
|
![moveToThread](ScreenShot/InheritQThread.png)
|
||||||
|
|
||||||
|
## 3、线程挂起恢复
|
||||||
|
[运行 SuspendThread.py](SuspendThread.py)
|
||||||
|
|
||||||
|
注意,这里只是简单演示,在应用这些代码时要小心
|
||||||
|
|
||||||
|
1. 这里使用windows的api实现,主要用到`SuspendThread`和`ResumeThread`函数
|
||||||
|
1. 利用`ctypes.windll.kernel32.OpenThread(win32con.PROCESS_ALL_ACCESS, False, int(QThread.currentThreadId()))`
|
||||||
|
1. 得到线程的句柄,然后就可以通过上面的两个函数对其进行挂起与恢复
|
||||||
|
|
||||||
|
`ctypes.windll.kernel32.TerminateThread`终止线程,不推荐
|
||||||
|
|
||||||
|
![SuspendThread](ScreenShot/SuspendThread.gif)
|
||||||
|
|
||||||
|
## 4、线程休眠唤醒
|
||||||
|
[运行 WakeupThread.py](WakeupThread.py)
|
||||||
|
|
||||||
|
使用 `QWaitCondition` 的 `wait` 和 `wakeAll` 方法
|
||||||
|
|
||||||
|
![WakeupThread](ScreenShot/WakeupThread.gif)
|
BIN
QThread/ScreenShot/InheritQThread.png
Normal file
BIN
QThread/ScreenShot/InheritQThread.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
|
@ -1,25 +0,0 @@
|
||||||
# 多线程
|
|
||||||
|
|
||||||
PyQt多线程的简单使用例子
|
|
||||||
|
|
||||||
## [1、继承QThread](继承QThread.py)
|
|
||||||
|
|
||||||
## [2、moveToThread](moveToThread.py)
|
|
||||||
|
|
||||||
## [3、线程挂起恢复](线程挂起恢复.py)
|
|
||||||
|
|
||||||
注意,这里只是简单演示,在应用这些代码时要小心
|
|
||||||
|
|
||||||
1. 这里使用windows的api实现,主要用到`SuspendThread`和`ResumeThread`函数
|
|
||||||
1. 利用`ctypes.windll.kernel32.OpenThread(win32con.PROCESS_ALL_ACCESS, False, int(QThread.currentThreadId()))`
|
|
||||||
1. 得到线程的句柄,然后就可以通过上面的两个函数对其进行挂起与恢复
|
|
||||||
|
|
||||||
`ctypes.windll.kernel32.TerminateThread`终止线程,不推荐
|
|
||||||
|
|
||||||
![截图](ScreenShot/线程挂起恢复.gif)
|
|
||||||
|
|
||||||
## [4、线程休眠唤醒](线程休眠唤醒.py)
|
|
||||||
|
|
||||||
使用`QWaitCondition`的wait和wakeAll方法
|
|
||||||
|
|
||||||
![截图](ScreenShot/线程休眠唤醒.gif)
|
|
Loading…
Reference in a new issue