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


Python QtCore.qRound方法代码示例

本文整理汇总了Python中PyQt4.QtCore.qRound方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.qRound方法的具体用法?Python QtCore.qRound怎么用?Python QtCore.qRound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore的用法示例。


在下文中一共展示了QtCore.qRound方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: paint

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qRound [as 别名]
    def paint(self, painter, option=None, widget=None):
        if self.validateImage():
            wasSmoothPixmapTransform = painter.testRenderHint(QtGui.QPainter.SmoothPixmapTransform)
            painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform)

            if Colors.noRescale:
                # Let the painter scale the image for us.  This may degrade
                # both quality and performance.
                if self.sharedImage.image is not None:
                    painter.drawImage(self.pos(), self.sharedImage.image)
                else:
                    painter.drawPixmap(self.pos(), self.sharedImage.pixmap)
            else:
                m = painter.worldMatrix()
                painter.setWorldMatrix(QtGui.QMatrix())

                x = m.dx()
                y = m.dy()
                if self.noSubPixeling:
                    x = QtCore.qRound(x)
                    y = QtCore.qRound(y)

                if self.sharedImage.image is not None:
                    painter.drawImage(QtCore.QPointF(x, y),
                            self.sharedImage.image)
                else:
                    painter.drawPixmap(QtCore.QPointF(x, y),
                            self.sharedImage.pixmap)

            if not wasSmoothPixmapTransform:
                painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform,
                        False)
开发者ID:CapB1ack,项目名称:PyQt4,代码行数:34,代码来源:demoitem.py

示例2: drawBackgroundToPixmap

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qRound [as 别名]
    def drawBackgroundToPixmap(self):
        r = self.scene.sceneRect()
        self.background = QtGui.QPixmap(QtCore.qRound(r.width()),
                QtCore.qRound(r.height()))
        self.background.fill(QtCore.Qt.black)
        painter = QtGui.QPainter(self.background)

        bg = QtGui.QImage(':/images/demobg.png')
        painter.drawImage(0, 0, bg)
开发者ID:ClydeMojura,项目名称:android-python27,代码行数:11,代码来源:mainwindow.py

示例3: paint

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qRound [as 别名]
    def paint(self, glyph, painter, rect, mode, state, options):
        painter.save()

        #set the correct color
        color = options.get("color")
        text = options.get("text")

        if mode == QtGui.QIcon.Disabled:
            color = options.get("color-disabled")
            alt = options.get("text-disabled") 
            if alt:
                text = "%s" % alt
        elif mode == QtGui.QIcon.Active:
            color = options.get("color-active")
            alt = options.get("text-active")
            if alt:
                text = "%s" % alt
        elif mode == QtGui.QIcon.Selected:
            color = options.get("color-selected")
            alt = options.get("text-selected")
            if alt:
                text = "%s" % alt
            
        painter.setPen(color)

        # add some 'padding' around the icon
        drawSize = QtCore.qRound(rect.height() * options.get("scale-factor"))
        painter.setFont(glyph.font(drawSize))
        painter.drawText(rect, QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter, text)
        painter.restore()
开发者ID:diegomvh,项目名称:pyqt,代码行数:32,代码来源:glyph.py

示例4: shotRect

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qRound [as 别名]
    def shotRect(self):
        gravity = 4.0

        time = self.timerCount / 20.0
        velocity = self.shootForce
        radians = math.radians(self.shootAngle)

        velx = velocity * math.cos(radians)
        vely = velocity * math.sin(radians)
        x0 = (self.barrelRect.right() + 5) * math.cos(radians)
        y0 = (self.barrelRect.right() + 5) * math.sin(radians)
        x = x0 + velx * time
        y = y0 + vely * time - 0.5 * gravity * time * time

        result = QtCore.QRect(0, 0, 6, 6)
        result.moveCenter(QtCore.QPoint(QtCore.qRound(x), self.height() - 1 - QtCore.qRound(y)))
        return result
开发者ID:coderbone,项目名称:arsenalsuite,代码行数:19,代码来源:t11.py

示例5: mouseMoveEvent

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qRound [as 别名]
    def mouseMoveEvent(self, event):
        if not self.barrelPressed:
            return

        pos = event.pos()
        if pos.x() <= 0:
            pos.setX(1)
        if pos.y() >= self.height():
            pos.setY(self.height() - 1)

        rad = math.atan((float(self.rect().bottom()) - pos.y()) / pos.x())
        self.setAngle(QtCore.qRound(math.degrees(rad)))
开发者ID:attila3d,项目名称:arsenalsuite,代码行数:14,代码来源:t14.py


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