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


Python QtCore.qRound方法代码示例

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


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

示例1: paint

# 需要导入模块: from PySide2 import QtCore [as 别名]
# 或者: from PySide2.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:felipebetancur,项目名称:pyside2-examples,代码行数:34,代码来源:demoitem.py

示例2: drawBackgroundToPixmap

# 需要导入模块: from PySide2 import QtCore [as 别名]
# 或者: from PySide2.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:felipebetancur,项目名称:pyside2-examples,代码行数:11,代码来源:mainwindow.py

示例3: shotRect

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

        time = self.timerCount / 40.0
        velocity = self.shootForce
        radians = self.shootAngle * 3.14159265 / 180

        velx = velocity * math.cos(radians)
        vely = velocity * math.sin(radians)
        x0 = (CannonField.barrelRect.right() + 5) * math.cos(radians)
        y0 = (CannonField.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:felipebetancur,项目名称:pyside2-examples,代码行数:19,代码来源:t14.py

示例4: mouseMoveEvent

# 需要导入模块: from PySide2 import QtCore [as 别名]
# 或者: from PySide2.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(rad * 180 / 3.14159265))
开发者ID:felipebetancur,项目名称:pyside2-examples,代码行数:12,代码来源:t14.py


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