本文整理汇总了Python中PyQt4.QtCore.QDataStream.readQVariant方法的典型用法代码示例。如果您正苦于以下问题:Python QDataStream.readQVariant方法的具体用法?Python QDataStream.readQVariant怎么用?Python QDataStream.readQVariant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QDataStream
的用法示例。
在下文中一共展示了QDataStream.readQVariant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mime_data
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import readQVariant [as 别名]
def test_mime_data(self):
class DummyItem(object):
def data(s, role):
self.assertEqual(role, Qt.UserRole)
return 42
mw = self._get_one()
data = mw.mimeData([DummyItem()]).data('application/vnd.re-eat.meal_recipe')
stream = QDataStream(data, QIODevice.ReadOnly)
self.assertEqual(stream.readInt(), 42)
self.assertEqual(stream.readQVariant(), mw.date)
self.assertEqual(stream.readInt(), mw.index)
示例2: dropMimeData
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import readQVariant [as 别名]
def dropMimeData(self, index, data, action):
if action == Qt.IgnoreAction:
return True
if data.hasFormat('application/vnd.re-eat.meal_recipe'):
encodedData = data.data('application/vnd.re-eat.meal_recipe')
stream = QDataStream(encodedData, QIODevice.ReadOnly)
while not stream.atEnd():
id = stream.readInt()
date = stream.readQVariant()
index = stream.readInt()
self.recipeRemoved.emit(id, date, index)
return True
return False