本文整理匯總了Python中pyqtcore.QVector.count方法的典型用法代碼示例。如果您正苦於以下問題:Python QVector.count方法的具體用法?Python QVector.count怎麽用?Python QVector.count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyqtcore.QVector
的用法示例。
在下文中一共展示了QVector.count方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Zoomable
# 需要導入模塊: from pyqtcore import QVector [as 別名]
# 或者: from pyqtcore.QVector import count [as 別名]
#.........這裏部分代碼省略.........
elif (delta >= 120):
self.zoomIn()
else:
# We're dealing with a finer-resolution mouse. Allow it to have finer
# control over the zoom level.
factor = 1 + 0.3 * qAbs(delta / 8 / 15)
if (delta < 0):
factor = 1 / factor
scale = qBound(self.mZoomFactors.first(),
self.mScale * factor,
self.mZoomFactors.back())
# Round to at most four digits after the decimal point
self.setScale(math.floor(scale * 10000 + 0.5) / 10000)
##
# Changes the current scale based on the given pinch gesture.
##
def handlePinchGesture(self, pinch):
if (not (pinch.changeFlags() & QPinchGesture.ScaleFactorChanged)):
return
x = pinch.state()
if x==Qt.NoGesture:
pass
elif x==Qt.GestureStarted:
self.mGestureStartScale = self.mScale
# fall through
elif x==Qt.GestureUpdated:
factor = pinch.scaleFactor()
scale = qBound(self.mZoomFactors.first(),
self.mGestureStartScale * factor,
self.mZoomFactors.back())
self.setScale(math.floor(scale * 10000 + 0.5) / 10000)
elif x==Qt.GestureFinished:
pass
elif x==Qt.GestureCanceled:
pass
##
# Returns whether images should be smoothly transformed when drawn at the
# current scale. This is the case when the scale is not 1 and smaller than
# 2.
##
def smoothTransform(self):
return self.mScale != 1.0 and self.mScale < 2.0
def setZoomFactors(self, factors):
self.mZoomFactors = factors
def connectToComboBox(self, comboBox):
if (self.mComboBox):
self.mComboBox.disconnect()
if (self.mComboBox.lineEdit()):
self.mComboBox.lineEdit().disconnect()
self.mComboBox.setValidator(None)
self.mComboBox = comboBox
if type(comboBox) is QComboBox:
self.mComboBox.clear()
for scale in self.mZoomFactors:
self.mComboBox.addItem(scaleToString(scale), scale)
self.syncComboBox()
self.mComboBox.activated.connect(self.comboActivated)
self.mComboBox.setEditable(True)
self.mComboBox.setInsertPolicy(QComboBox.NoInsert)
self.mComboBox.lineEdit().editingFinished.connect(self.comboEdited)
if (not self.mComboValidator):
self.mComboValidator = QRegExpValidator(self.mComboRegExp, self)
self.mComboBox.setValidator(self.mComboValidator)
def zoomIn(self):
for scale in self.mZoomFactors:
if (scale > self.mScale):
self.setScale(scale)
break
def zoomOut(self):
for i in range(self.mZoomFactors.count() - 1, -1, -1):
if (self.mZoomFactors[i] < self.mScale):
self.setScale(self.mZoomFactors[i])
break
def resetZoom(self):
self.setScale(1)
def comboActivated(self, index):
self.setScale(self.mComboBox.itemData(index))
def comboEdited(self):
pos = self.mComboRegExp.indexIn(self.mComboBox.currentText())
pos != -1
scale = qBound(self.mZoomFactors.first(), Float(self.mComboRegExp.cap(1)) / 100.0, self.mZoomFactors.last())
self.setScale(scale)
def syncComboBox(self):
if (not self.mComboBox):
return
index = self.mComboBox.findData(self.mScale)
# For a custom scale, the current index must be set to -1
self.mComboBox.setCurrentIndex(index)
self.mComboBox.setEditText(scaleToString(self.mScale))