本文整理匯總了Python中PyQt4.QtCore.QRect方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QRect方法的具體用法?Python QtCore.QRect怎麽用?Python QtCore.QRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtCore
的用法示例。
在下文中一共展示了QtCore.QRect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: drawDisp
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def drawDisp( self , qp ):
if not self.dispOverlay:
return
# Save QPainter settings to stack
qp.save()
# Define transparency
qp.setOpacity(self.transp)
# Draw the overlay image
qp.drawImage(QtCore.QRect( self.xoff, self.yoff, self.w, self.h ),self.dispOverlay)
# Restore settings
qp.restore()
return self.dispOverlay
#############################
## Mouse/keyboard events
#############################
# Mouse moved
# Need to save the mouse position
# Need to drag a polygon point
# Need to update the mouse selected object
示例2: doLayout
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def doLayout(self, rect, testOnly):
x = rect.x()
y = rect.y()
lineHeight = 0
for item in self.itemList:
wid = item.widget()
spaceX = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton,
QtGui.QSizePolicy.PushButton, QtCore.Qt.Horizontal)
spaceY = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton,
QtGui.QSizePolicy.PushButton, QtCore.Qt.Vertical)
nextX = x + item.sizeHint().width() + spaceX
if nextX - spaceX > rect.right() and lineHeight > 0:
x = rect.x()
y = y + lineHeight + spaceY
nextX = x + item.sizeHint().width() + spaceX
lineHeight = 0
if not testOnly:
item.setGeometry(QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint()))
x = nextX
lineHeight = max(lineHeight, item.sizeHint().height())
return y + lineHeight - rect.y()
示例3: drawDisp
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def drawDisp( self , qp ):
if not self.dispOverlay:
return
# Save QPainter settings to stack
qp.save()
# Define transparency
qp.setOpacity(self.transp)
# Draw the overlay image
qp.drawImage(QtCore.QRect( self.xoff, self.yoff, self.w, self.h ),self.dispOverlay)
# Restore settings
qp.restore()
return self.dispOverlay
#############################
## Mouse/keyboard events
#############################
# Mouse moved
# Need to save the mouse position
# Need to drag a polygon point
# Need to update the mouse selected object
示例4: registerCmap
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def registerCmap(self):
""" Add matplotlib cmaps to the GradientEditors context menu"""
self.gradientEditorItem.menu.addSeparator()
savedLength = self.gradientEditorItem.length
self.gradientEditorItem.length = 100
for name in self.mplColorMaps:
px = QPixmap(100, 15)
p = QPainter(px)
self.gradientEditorItem.restoreState(self.mplColorMaps[name])
grad = self.gradientEditorItem.getGradient()
brush = QBrush(grad)
p.fillRect(QtCore.QRect(0, 0, 100, 15), brush)
p.end()
label = QLabel()
label.setPixmap(px)
label.setContentsMargins(1, 1, 1, 1)
act =QWidgetAction(self.gradientEditorItem)
act.setDefaultWidget(label)
act.triggered.connect(self.cmapClicked)
act.name = name
self.gradientEditorItem.menu.addAction(act)
self.gradientEditorItem.length = savedLength
示例5: centerScaleRect
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def centerScaleRect(rect, scale):
"""
centerScaleRect(QRect rect, float scale) -> QRect scaled
Takes a QRect and a float scale value, and returns a copy
of the rect that has been scaled around the center point.
"""
scaledRect = QtCore.QRect(rect)
size = scaledRect.size()
pos = scaledRect.center()
offset = QtCore.QPoint(
pos.x() - (size.width()*.5),
pos.y() - (size.height()*.5))
scaledRect.moveCenter(offset)
scaledRect.setSize(size * scale)
scaledRect.moveCenter(pos)
return scaledRect
示例6: doLayout
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def doLayout(self, rect, testOnly):
x = rect.x()
y = rect.y()
lineHeight = 0
for item in self.itemList:
wid = item.widget()
spaceX = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Horizontal)
spaceY = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Vertical)
nextX = x + item.sizeHint().width() + spaceX
if nextX - spaceX > rect.right() and lineHeight > 0:
x = rect.x()
y = y + lineHeight + spaceY
nextX = x + item.sizeHint().width() + spaceX
lineHeight = 0
if not testOnly:
item.setGeometry(QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint()))
x = nextX
lineHeight = max(lineHeight, item.sizeHint().height())
return y + lineHeight - rect.y()
示例7: setupUi
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(400, 300)
self.pushButton = QtGui.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(250, 140, 75, 23))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.lineEdit = QtGui.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(50, 140, 191, 20))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.label = QtGui.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(100, 180, 201, 51))
font = QtGui.QFont()
font.setPointSize(20)
self.label.setFont(font)
self.label.setObjectName(_fromUtf8("label"))
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
示例8: setupUi
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(400, 240)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.checkBox = QtGui.QCheckBox(self.centralwidget)
self.checkBox.setGeometry(QtCore.QRect(130, 80, 151, 41))
font = QtGui.QFont()
font.setPointSize(32)
self.checkBox.setFont(font)
self.checkBox.setObjectName(_fromUtf8("checkBox"))
#MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 400, 21))
self.menubar.setObjectName(_fromUtf8("menubar"))
#MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
#MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例9: showCode
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def showCode(self):
pixmap = QtGui.QPixmap()
pixmap.load("api/code.jpg")
pixmap.scaledToHeight(60)
pixmap.scaledToWidth(120)
self.scene_code = QtGui.QGraphicsScene(self)
item = QtGui.QGraphicsPixmapItem(pixmap)
self.scene_code.addItem(item)
self.ui.img_code.setScene(self.scene_code)
self.resize(257, 235)
self.ui.lbl_code.setGeometry(QtCore.QRect(20, 110, 63, 18))
self.ui.text_code.setGeometry(QtCore.QRect(70, 100, 113, 28))
self.ui.img_code.setGeometry(QtCore.QRect(60, 130, 120, 50))
self.ui.btn_login.setGeometry(QtCore.QRect(20, 190, 93, 27))
self.ui.btn_cancel.setGeometry(QtCore.QRect(140, 190, 93, 27))
self.ui.lbl_code.show()
self.ui.text_code.show()
self.ui.img_code.show()
# chat
示例10: createWidget_recent
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def createWidget_recent(self,listWidget,uin,flag):
self.listWidgetItem = QtGui.QListWidgetItem(listWidget)
self.listWidgetItem.setSizeHint(QtCore.QSize(0, 48))
self.widget = QtGui.QWidget()
self.widget.setProperty('uin',str(uin)+':'+str(flag))
self.widget.setGeometry(QtCore.QRect(0, 0, 238, 51))
self.graphicsView_recent[uin] = QtGui.QGraphicsView(self.widget)
self.graphicsView_recent[uin].setGeometry(QtCore.QRect(1, 1, 60, 60))
if flag==0:
self.graphicsView_recent[uin].setScene(self.createImg('user',uin))
title=self.userdict[uin]['nickname']
if flag==1:
title=self.groupdict[uin]['name']
self.graphicsView_recent[uin].setScene(self.createImg('group',uin))
if flag==2:
title=self.discussdict[uin]['name']
self.graphicsView_recent[uin].setScene(self.createImg('discuss',uin))
self.graphicsView_recent[uin].resize(50,50)
self.lbl_title = QtGui.QLabel(self.widget)
self.lbl_title.setGeometry(QtCore.QRect(60, 10, 181, 18))
self.lbl_title.setFont(self.font2)
self.lbl_title.setText(_translate("Main", title, None))
return self.listWidgetItem, self.widget
示例11: drawImage
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def drawImage(self, qp):
# Return if no image available
if self.image.isNull():
return
# Save the painters current setting to a stack
qp.save()
# Draw the image
qp.drawImage(QtCore.QRect( self.xoff, self.yoff, self.w, self.h ), self.image)
# Restore the saved setting from the stack
qp.restore()
示例12: setupUi
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(529, 329)
self.selInfoWidget = QtGui.QWidget(Form)
self.selInfoWidget.setGeometry(QtCore.QRect(260, 10, 264, 222))
self.selInfoWidget.setObjectName(_fromUtf8("selInfoWidget"))
self.gridLayout = QtGui.QGridLayout(self.selInfoWidget)
self.gridLayout.setMargin(0)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.selDescLabel = QtGui.QLabel(self.selInfoWidget)
self.selDescLabel.setText(_fromUtf8(""))
self.selDescLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.selDescLabel.setWordWrap(True)
self.selDescLabel.setObjectName(_fromUtf8("selDescLabel"))
self.gridLayout.addWidget(self.selDescLabel, 0, 0, 1, 1)
self.selNameLabel = QtGui.QLabel(self.selInfoWidget)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.selNameLabel.setFont(font)
self.selNameLabel.setText(_fromUtf8(""))
self.selNameLabel.setObjectName(_fromUtf8("selNameLabel"))
self.gridLayout.addWidget(self.selNameLabel, 0, 1, 1, 1)
self.selectedTree = DataTreeWidget(self.selInfoWidget)
self.selectedTree.setObjectName(_fromUtf8("selectedTree"))
self.selectedTree.headerItem().setText(0, _fromUtf8("1"))
self.gridLayout.addWidget(self.selectedTree, 1, 0, 1, 2)
self.hoverText = QtGui.QTextEdit(Form)
self.hoverText.setGeometry(QtCore.QRect(0, 240, 521, 81))
self.hoverText.setObjectName(_fromUtf8("hoverText"))
self.view = FlowchartGraphicsView(Form)
self.view.setGeometry(QtCore.QRect(0, 0, 256, 192))
self.view.setObjectName(_fromUtf8("view"))
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
示例13: heightForWidth
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def heightForWidth(self, width):
height = self.doLayout(QtCore.QRect(0, 0, width, 0), True)
return height
示例14: minimizeWindows
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def minimizeWindows(self, id):
hwnds = []
maxHwnd = GetWindowHandle()
threadID = GetCurrentThreadId()
EnumThreadWindows( threadID, self.EnumWindowsProc, hwnds)
pnt = ClientToScreen(id,(5,5))
pnt = QPoint(pnt[0], pnt[1])
for hwnd in hwnds:
if hwnd != maxHwnd:
rect = GetWindowRect(hwnd)
if QRect(QPoint(rect[0], rect[1]), QPoint(rect[2], rect[3])).contains(pnt) and IsWindowVisible(hwnd):
# print hwnd, GetWindowRect(hwnd), GetWindowText(hwnd), GetClassName(hwnd), IsWindowVisible(hwnd)
self.minimzedWindows.append(hwnd)
ShowWindow( hwnd, win32con.SW_MINIMIZE )
示例15: findRect
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRect [as 別名]
def findRect( self, name ):
from PyQt4.QtCore import QRect
return self._findRect( name, QRect, int )