本文整理汇总了Python中PyQt5.QtCore.QSize.setHeight方法的典型用法代码示例。如果您正苦于以下问题:Python QSize.setHeight方法的具体用法?Python QSize.setHeight怎么用?Python QSize.setHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QSize
的用法示例。
在下文中一共展示了QSize.setHeight方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: maxSize
# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import setHeight [as 别名]
def maxSize(self):
size = QSize()
for variation in self.d.variations:
size.setWidth(max(size.width(), variation.map.width()))
size.setHeight(max(size.height(), variation.map.height()))
return size
示例2: mapSize
# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import setHeight [as 别名]
def mapSize(self):
p = RenderParams(self.map())
# The map size is the same regardless of which indexes are shifted.
if (p.staggerX):
size = QSize(self.map().width() * p.columnWidth + p.sideOffsetX,
self.map().height() * (p.tileHeight + p.sideLengthY))
if (self.map().width() > 1):
size.setHeight(size.height() + p.rowHeight)
return size
else:
size = QSize(self.map().width() * (p.tileWidth + p.sideLengthX),
self.map().height() * p.rowHeight + p.sideOffsetY)
if (self.map().height() > 1):
size.setWidth(size.width() + p.columnWidth)
return size
示例3: calculate_size
# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import setHeight [as 别名]
def calculate_size(self):
"""Determine size by calculating the space of the visible items"""
visible_items = min(self.model().rowCount(), self.MAX_VISIBLE_ITEMS)
first_visible_row = self.verticalScrollBar().value()
option = self.viewOptions()
size_hint = QSize()
for index in range(visible_items):
tmp_size = self.itemDelegate().sizeHint(
option, self.model().index(index + first_visible_row, 0))
if size_hint.width() < tmp_size.width():
size_hint = tmp_size
height = size_hint.height()
height *= visible_items
size_hint.setHeight(height)
return size_hint
示例4: setColor
# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import setHeight [as 别名]
def setColor(self, color):
if type(color)!=QColor:
color = QColor(color)
if (self.mColor == color or not color.isValid()):
return
self.mColor = color
size = QSize(self.iconSize())
size.setWidth(size.width()-2)
size.setHeight(size.height()-2)
pixmap = QPixmap(size)
pixmap.fill(self.mColor)
painter = QPainter(pixmap)
border = QColor(Qt.black)
border.setAlpha(128)
painter.setPen(border)
painter.drawRect(0, 0, pixmap.width() - 1, pixmap.height() - 1)
painter.end()
self.setIcon(QIcon(pixmap))
self.colorChanged.emit(color)
示例5: calculateSize
# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import setHeight [as 别名]
def calculateSize(self, sizeType):
totalSize = QSize()
for wrapper in self.list:
position = wrapper.position
itemSize = QSize()
if sizeType == self.MinimumSize:
itemSize = wrapper.item.minimumSize()
else: # sizeType == self.SizeHint
itemSize = wrapper.item.sizeHint()
if position in (self.North, self.South, self.Center):
totalSize.setHeight(totalSize.height() + itemSize.height())
if position in (self.West, self.East, self.Center):
totalSize.setWidth(totalSize.width() + itemSize.width())
return totalSize
示例6: ResizeHelper
# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import setHeight [as 别名]
class ResizeHelper(QWidget):
offsetChanged = pyqtSignal(QPoint)
offsetXChanged = pyqtSignal(int)
offsetYChanged = pyqtSignal(int)
offsetBoundsChanged = pyqtSignal(QRect)
def __init__(self, parent = None):
super().__init__(parent)
self.mMouseAnchorPoint = QPoint()
self.mOffset = QPoint()
self.mOldSize = QSize()
self.mDragging = False
self.mOffsetBounds = QRect()
self.mScale = 0.0
self.mNewSize = QSize()
self.mOrigOffset = QPoint()
self.setMinimumSize(20, 20)
self.setOldSize(QSize(1, 1))
def oldSize(self):
return self.mOldSize
def newSize(self):
return self.mNewSize
def offset(self):
return self.mOffset
def offsetBounds(self):
return self.mOffsetBounds
def setOldSize(self, size):
self.mOldSize = size
self.recalculateMinMaxOffset()
self.recalculateScale()
def setNewSize(self, size):
self.mNewSize = size
self.recalculateMinMaxOffset()
self.recalculateScale()
def setOffset(self, offset):
# Clamp the offset within the offset bounds
newOffset = QPoint(min(self.mOffsetBounds.right(),
max(self.mOffsetBounds.left(), offset.x())),
min(self.mOffsetBounds.bottom(),
max(self.mOffsetBounds.top(), offset.y())))
if (self.mOffset != newOffset):
xChanged = self.mOffset.x() != newOffset.x()
yChanged = self.mOffset.y() != newOffset.y()
self.mOffset = newOffset
if (xChanged):
self.offsetXChanged.emit(self.mOffset.x())
if (yChanged):
self.offsetYChanged.emit(self.mOffset.y())
self.offsetChanged.emit(self.mOffset)
self.update()
## Method to set only the X offset, provided for convenience. */
def setOffsetX(self, x):
self.setOffset(QPoint(x, self.mOffset.y()))
## Method to set only the Y offset, provided for convenience. */
def setOffsetY(self, y):
self.setOffset(QPoint(self.mOffset.x(), y))
## Method to set only new width, provided for convenience. */
def setNewWidth(self, width):
self.mNewSize.setWidth(width)
self.recalculateMinMaxOffset()
self.recalculateScale()
## Method to set only new height, provided for convenience. */
def setNewHeight(self, height):
self.mNewSize.setHeight(height)
self.recalculateMinMaxOffset()
self.recalculateScale()
def paintEvent(self, event):
_size = self.size() - QSize(2, 2)
if (_size.isEmpty()):
return
origX = (_size.width() - self.mNewSize.width() * self.mScale) / 2 + 0.5
origY = (_size.height() - self.mNewSize.height() * self.mScale) / 2 + 0.5
oldRect = QRect(self.mOffset, self.mOldSize)
painter = QPainter(self)
painter.translate(origX, origY)
painter.scale(self.mScale, self.mScale)
pen = QPen(Qt.black)
pen.setCosmetic(True)
painter.setPen(pen)
painter.drawRect(QRect(QPoint(0, 0), self.mNewSize))
pen.setColor(Qt.white)
painter.setPen(pen)
painter.setBrush(Qt.white)
painter.setOpacity(0.5)
painter.drawRect(oldRect)
pen.setColor(Qt.black)
#.........这里部分代码省略.........
示例7: TileLayer
# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import setHeight [as 别名]
#.........这里部分代码省略.........
self.mGrid = newGrid
##
# Rotate this tile layer by 90 degrees left or right. The tile positions
# are rotated within the layer, and the tiles themselves are rotated. The
# dimensions of the tile layer are swapped.
##
def rotate(self, direction):
rotateRightMask = [5, 4, 1, 0, 7, 6, 3, 2]
rotateLeftMask = [3, 2, 7, 6, 1, 0, 5, 4]
if direction == RotateDirection.RotateRight:
rotateMask = rotateRightMask
else:
rotateMask = rotateLeftMask
newWidth = self.mHeight
newHeight = self.mWidth
newGrid = QVector(newWidth * newHeight)
for y in range(self.mHeight):
for x in range(self.mWidth):
source = self.cellAt(x, y)
dest = source
mask = (dest.flippedHorizontally << 2) | (dest.flippedVertically << 1) | (dest.flippedAntiDiagonally << 0)
mask = rotateMask[mask]
dest.flippedHorizontally = (mask & 4) != 0
dest.flippedVertically = (mask & 2) != 0
dest.flippedAntiDiagonally = (mask & 1) != 0
if (direction == RotateDirection.RotateRight):
newGrid[x * newWidth + (self.mHeight - y - 1)] = dest
else:
newGrid[(self.mWidth - x - 1) * newWidth + y] = dest
t = self.mMaxTileSize.width()
self.mMaxTileSize.setWidth(self.mMaxTileSize.height())
self.mMaxTileSize.setHeight(t)
self.mWidth = newWidth
self.mHeight = newHeight
self.mGrid = newGrid
##
# Computes and returns the set of tilesets used by this tile layer.
##
def usedTilesets(self):
tilesets = QSet()
i = 0
while(i<self.mGrid.size()):
tile = self.mGrid.at(i).tile
if tile:
tilesets.insert(tile.tileset())
i += 1
return tilesets
##
# Returns whether this tile layer has any cell for which the given
# \a condition returns True.
##
def hasCell(self, condition):
i = 0
for cell in self.mGrid:
if (condition(cell)):
return True
i += 1
return False
##
# Returns whether this tile layer is referencing the given tileset.
##