本文整理汇总了Python中PyQt4.QtCore.QByteArray.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Python QByteArray.isEmpty方法的具体用法?Python QByteArray.isEmpty怎么用?Python QByteArray.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QByteArray
的用法示例。
在下文中一共展示了QByteArray.isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Level
# 需要导入模块: from PyQt4.QtCore import QByteArray [as 别名]
# 或者: from PyQt4.QtCore.QByteArray import isEmpty [as 别名]
#.........这里部分代码省略.........
def addText(self):
item = TextItem("SomeText", self.position())
self.connect(item, SIGNAL("current"),self.current)
self.connect(item, SIGNAL("copy"),self.copy)
self.connect(item, SIGNAL("cut"),self.cut)
self.connect(item, SIGNAL("paste"),self.paste)
self.connect(item, SIGNAL("delete"),self.delete)
#self.current(item)
self.scene.addItem(item)
def copy(self):
item = self.selectedItem()
if item is None:
return
self.copiedItem.clear()
self.pasteOffset = 5
stream = QDataStream(self.copiedItem, QIODevice.WriteOnly)
self.writeItemToStream(stream, item)
def cut(self):
item = self.selectedItem()
if item is None:
return
self.copy()
self.scene.removeItem(item)
del item
def paste(self):
if self.copiedItem.isEmpty():
return
stream = QDataStream(self.copiedItem, QIODevice.ReadOnly)
item = self.readItemFromStream(stream, self.pasteOffset)
self.pasteOffset += 5
#self.scene.addItem(item)
def delete(self):
items = self.scene.selectedItems()
if (len(items) and QMessageBox.question(self,
"Designer - Delete",
"Delete {0} item{1}?".format(len(items),
"s" if len(items) != 1 else ""),
QMessageBox.Yes|QMessageBox.No) ==
QMessageBox.Yes):
while items:
item = items.pop()
self.scene.removeItem(item)
del item
def readItemFromStream(self, stream, offset=0):
type = QString()
position = QPointF()
matrix = QMatrix()
stream >> type >> position >> matrix
if offset:
position += QPointF(offset, offset)
if type == "Text":
text = QString()
font = QFont()
stream >> text >> font
self.scene.addItem(TextItem(text, position, font, matrix))
elif type == "Box":