当前位置: 首页>>代码示例>>Python>>正文


Python QDataStream.writeQVariant方法代码示例

本文整理汇总了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)])
开发者ID:madjar,项目名称:re-eat,代码行数:35,代码来源:test_meals.py

示例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
开发者ID:madjar,项目名称:re-eat,代码行数:13,代码来源:meals.py

示例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)])
开发者ID:madjar,项目名称:re-eat,代码行数:22,代码来源:test_recipes.py


注:本文中的PyQt4.QtCore.QDataStream.writeQVariant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。