本文整理汇总了Python中PyQt4.QtCore.QDataStream.writeQVariant方法的典型用法代码示例。如果您正苦于以下问题:Python QDataStream.writeQVariant方法的具体用法?Python QDataStream.writeQVariant怎么用?Python QDataStream.writeQVariant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QDataStream
的用法示例。
在下文中一共展示了QDataStream.writeQVariant方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dropping_the_data_emits_the_signal
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import writeQVariant [as 别名]
def test_dropping_the_data_emits_the_signal(self):
mw = self._get_one()
self.assertEqual(mw.supportedDropActions(),
Qt.CopyAction)
self.assertIn('application/vnd.re-eat.recipe', mw.mimeTypes())
assert mw.viewport().acceptDrops()
mw.recipeAdded = DummySignal()
mimeData = QMimeData()
encodedData = QByteArray()
stream = QDataStream(encodedData, QIODevice.WriteOnly)
stream.writeInt(1)
stream.writeInt(2)
mimeData.setData('application/vnd.re-eat.recipe', encodedData)
mw.dropMimeData(0, mimeData, Qt.CopyAction)
self.assertListEqual(mw.recipeAdded.received,
[(1, mw.date, mw.index),
(2, mw.date, mw.index)])
mw.recipeMoved = DummySignal()
mimeData = QMimeData()
encodedData = QByteArray()
stream = QDataStream(encodedData, QIODevice.WriteOnly)
stream.writeInt(42)
stream.writeQVariant(datetime.date.today())
stream.writeInt(2)
mimeData.setData('application/vnd.re-eat.meal_recipe', encodedData)
mw.dropMimeData(0, mimeData, Qt.CopyAction)
self.assertListEqual(mw.recipeMoved.received,
[(42, datetime.date.today(), 2, mw.date, mw.index)])
示例2: mimeData
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import writeQVariant [as 别名]
def mimeData(self, items):
mimeData = QMimeData()
encodedData = QByteArray()
stream = QDataStream(encodedData, QIODevice.WriteOnly)
for item in items:
id = item.data(Qt.UserRole)
stream.writeInt(id)
stream.writeQVariant(self.date)
stream.writeInt(self.index)
mimeData.setData('application/vnd.re-eat.meal_recipe', encodedData)
return mimeData
示例3: test_dropping_the_data_emits_the_signal
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import writeQVariant [as 别名]
def test_dropping_the_data_emits_the_signal(self):
rw = RecipesWidget()
self.assertEqual(rw.supportedDropActions(),
Qt.CopyAction|Qt.MoveAction)
self.assertIn('application/vnd.re-eat.meal_recipe', rw.mimeTypes())
assert rw.viewport().acceptDrops()
rw.recipeRemoved = DummySignal()
mimeData = QMimeData()
encodedData = QByteArray()
stream = QDataStream(encodedData, QIODevice.WriteOnly)
stream.writeInt(1)
stream.writeQVariant(datetime.date.today())
stream.writeInt(2)
mimeData.setData('application/vnd.re-eat.meal_recipe', encodedData)
rw.dropMimeData(0, mimeData, Qt.CopyAction)
self.assertListEqual(rw.recipeRemoved.received,
[(1, datetime.date.today(), 2)])