本文整理匯總了Python中qt.QObject.emit方法的典型用法代碼示例。如果您正苦於以下問題:Python QObject.emit方法的具體用法?Python QObject.emit怎麽用?Python QObject.emit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qt.QObject
的用法示例。
在下文中一共展示了QObject.emit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _TableModelProxy
# 需要導入模塊: from qt import QObject [as 別名]
# 或者: from qt.QObject import emit [as 別名]
class _TableModelProxy(object):
def __init__(self, *args):
self.super = super(self.__class__,self)
self.super.__init__(*args)
self.emitter = QObject()
self.selection = None
self.undoStack = UndoStack()
self.undoStackReadOnly = False
def setHeader(self, col, header):
self.super.setHeader(col, header)
self.emitter.emit(PYSIGNAL("setHeader"),(col,header))
def insertRow(self,i=None,row=None):
if i is None: i=len(self.table)
if self.super.insertRow(i,row):
for k in range(i,len(self.table)):
self.table[k].num = k
self.emitter.emit(PYSIGNAL("insertRow"),(i,self.table[i]))
if not self.undoStackReadOnly:
self.undoStack.push("insertRow",i,row)
return True
else:
return False
def insertColumn(self,i=None,col=None):
if self.super.insertColumn(i,col):
self.emitter.emit(PYSIGNAL("insertColumn"),(i,col))
if type(i)==int and i <= self.selection:
self.selection += 1
return True
else:
return False
def takeRow(self,i):
r = self.super.takeRow(i)
for k in range(i,len(self.table)):
self.table[k].num = k
if i == self.selection:
self.selection = None
self.emitter.emit(PYSIGNAL("takeRow"),(i,r))
if not self.undoStackReadOnly:
self.undoStack.push("takeRow",i,r)
return r
def takeColumn(self,i):
c = self.super.takeColumn(i)
self.emitter.emit(PYSIGNAL("takeColumn"),(i,))
if i == self.selection:
self.selection = None
elif i < self.selection:
self.selection -= 1
return c
def sort(self, *args):
self.super.sort(*args)
for i,row in enumerate(self.table):
row.num = i
self.emitter.emit(PYSIGNAL("sort"),())
def select(self, sel):
self.selection = sel
self.emitter.emit(PYSIGNAL("select"),(sel,))
def getSelection(self):
return self.selection
def resetUndoStack(self):
self.undoStack.reset()
def undo(self, n=1):
for m in range(n):
try:
op, arg1, arg2 = self.undoStack.prev()
#print "undo", op, arg1, arg2
#print len(self.undoStack._stack)
except TypeError:
break
self.undoStackReadOnly = True
if op == 'insertRow':
self.takeRow(arg1)
elif op == 'takeRow':
self.insertRow(arg1,arg2)
elif op == 'cellChanged':
i, j = arg1
v, w = arg2
self[i][j] = w
self.undoStackReadOnly = False
def redo(self, n=1):
for m in range(n):
try:
op, arg1, arg2 = self.undoStack.next()
#print "redo", op, arg1, arg2
#print len(self.undoStack._stack)
except TypeError:
break
self.undoStackReadOnly = True
if op == 'insertRow':
self.insertRow(arg1,arg2)
#.........這裏部分代碼省略.........