当前位置:网站首页>Some usage records about using pyqt5
Some usage records about using pyqt5
2022-06-25 15:09:00 【Solution_ Cen】
About use pyqt5 Some usage records
Environmental Science :Win10、Python3.7、Pyqt5 5.15
On the Internet pyqt5 There are not many detailed instructions for use , You can only try and error while using
Because it is an afterthought to record , I have to record some impressions I have encountered so far :
Detail related
1. The signal / Slot
To confirm and Pyqt5 The slot execution relationship between various form structures , Confirm the signal binding mode
The information found on the Internet says that signals can be activated through signals , Specific conditions have not been tested , At present, it is only clear that the following usage methods will make mistakes
Misuse :
In this case ,QtObjectB Of The signal B-1 Can't activate The signal A-1 Let's go QtObjectA Executive function A-1. Only by The signal B-1 Direct connection function A-1 For normal use ;
One of the ways that can be used successfully :
2.Run The process , perform QtThread, Application error ( No problem during debugging )
The estimate here is python The issue of execution ;
Details :
The use of PyCharm Development ,Debug There is no problem when , but Run Execute individual addition when QtThread The program will flash back , Background display error -1073740791 (0xC0000409), No other information .
because Debug There will be no problems when , Only in every sentence print Let's see what went wrong , Finally, it was found that there was an error when starting and running the child thread ;
I wrote a new simple class IOThread Inherit QtThread, Mainly to undertake some IO Mission , Here, I will create and execute in one statement , There is no named variable to accept :
def IOFunc(*arg, **karg):
#function
pass
Class IOThread(QtThread)
def __init__ (self, func, *arg, **karg):
self.func = func
self.arg = arg
self.karg = karg
def run(self)
self.func(*self.arg, **self.karg)
Class ObjectA(QtObject):
...
def FuncA(self):
...
IOThread(IOFunc, *Targ, **Tkarg).start() # This is written in PyCharm Run Will make mistakes , The written program will flash back
...
def FuncB(self):
...
temp = IOThread(IOFunc, *Targ, **Tkarg)
temp.start() # This is written in PyCharm Run Will make mistakes , The written program will flash back
...
def FuncC(self):
...
while True:
#IOThread(IOFunc).start() # This is written in PyCharm Run Will make mistakes , The written program will flash back
temp = IOThread(IOFunc, *Targ, **Tkarg)
temp.start() # This is written in PyCharm Run No mistakes
...
def FuncD(self):
...
self.temp = IOThread(IOFunc, *Targ, **Tkarg)
self.temp.start() # This is written in PyCharm Run No mistakes
...
...
Judging from the above , Should be python Run When compiling the code, you create QtThread Then I thought I had run out , Reclaim memory at the end of the function , Make a mistake . You need to keep it in the function manually ;FuncC Yes means that if the task of a child thread is to manage 、 New thread , You can allow local variables to remain .
For the time being, I am impressed by the above 2022 year 2 month 18 Japan .
边栏推荐
猜你喜欢

How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps

Iterator failure condition

Judging the number of leap years from 1 to N years

Custom structure type

Gif动画怎么在线制作?快试试这款gif在线制作工具

Arithmetic operations and expressions

QT excel table read / write library - qtxlsx

System Verilog — interface

Design and implementation of timer

Fishing detection software
随机推荐
Semaphore function
About the problem of kicad stuck in win10 version, version 6 x
basic_ String mind map
Common dynamic memory errors
2. operator and expression multiple choice questions
Solution of push code failure in idea
从0到1完全掌握 XSS
Review of arrays and pointers triggered by a topic
Business layer - upper and lower computer communication protocol
Automatic correlation between QT signal and slot
Time stamp calculation and audio-visual synchronization of TS stream combined video by ffmpeg protocol concat
[C language] implementation of magic square array (the most complete)
NBD Network Block Device
Build a minimalist gb28181 gatekeeper and gateway server, establish AI reasoning and 3D service scenarios, and then open source code (I)
System Verilog - data type
Clipboard tutorial
Errno perrno and strerrno
How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps
Function of getinstance() method
QT pop up open file dialog box QFileDialog