本文整理汇总了Python中PyQt5.QtCore.QByteArray.toInt方法的典型用法代码示例。如果您正苦于以下问题:Python QByteArray.toInt方法的具体用法?Python QByteArray.toInt怎么用?Python QByteArray.toInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QByteArray
的用法示例。
在下文中一共展示了QByteArray.toInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Connection
# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import toInt [as 别名]
#.........这里部分代码省略.........
"""
Private method to read some data into the buffer.
@param maxSize maximum size of data to read (integer)
@return size of data read (integer)
"""
if maxSize > MaxBufferSize:
return 0
numBytesBeforeRead = self.__buffer.size()
if numBytesBeforeRead == MaxBufferSize:
self.abort()
return 0
while self.bytesAvailable() and self.__buffer.size() < maxSize:
self.__buffer.append(self.read(1))
if self.__buffer.endsWith(SeparatorToken):
break
return self.__buffer.size() - numBytesBeforeRead
def __dataLengthForCurrentDataType(self):
"""
Private method to get the data length for the current data type.
@return data length (integer)
"""
if self.bytesAvailable() <= 0 or \
self.__readDataIntoBuffer() <= 0 or \
not self.__buffer.endsWith(SeparatorToken):
return 0
self.__buffer.chop(len(SeparatorToken))
number = self.__buffer.toInt()[0]
self.__buffer.clear()
return number
def __readProtocolHeader(self):
"""
Private method to read the protocol header.
@return flag indicating a successful read (boolean)
"""
if self.__transferTimerId:
self.killTimer(self.__transferTimerId)
self.__transferTimerId = 0
if self.__readDataIntoBuffer() <= 0:
self.__transferTimerId = self.startTimer(TransferTimeout)
return False
self.__buffer.chop(len(SeparatorToken))
if self.__buffer == Connection.ProtocolPing:
self.__currentDataType = Connection.Ping
elif self.__buffer == Connection.ProtocolPong:
self.__currentDataType = Connection.Pong
elif self.__buffer == Connection.ProtocolMessage:
self.__currentDataType = Connection.PlainText
elif self.__buffer == Connection.ProtocolGreeting:
self.__currentDataType = Connection.Greeting
elif self.__buffer == Connection.ProtocolGetParticipants:
self.__currentDataType = Connection.GetParticipants
elif self.__buffer == Connection.ProtocolParticipants:
self.__currentDataType = Connection.Participants
elif self.__buffer == Connection.ProtocolEditor:
self.__currentDataType = Connection.Editor