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


Python QRect.setTop方法代码示例

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


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

示例1: paint

# 需要导入模块: from PyQt4.Qt import QRect [as 别名]
# 或者: from PyQt4.Qt.QRect import setTop [as 别名]
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, QModelIndex())  # draw the hover and selection highlights
     m = index.model()
     db = m.db
     try:
         book_id = db.id(index.row())
     except (ValueError, IndexError, KeyError):
         return
     if book_id in m.ids_to_highlight_set:
         painter.save()
         try:
             painter.setPen(self.highlight_color)
             painter.setRenderHint(QPainter.Antialiasing, True)
             painter.drawRoundedRect(option.rect, 10, 10, Qt.RelativeSize)
         finally:
             painter.restore()
     marked = db.data.get_marked(book_id)
     db = db.new_api
     cdata = self.cover_cache[book_id]
     device_connected = self.parent().gui.device_connected is not None
     on_device = device_connected and db.field_for('ondevice', book_id)
     painter.save()
     right_adjust = 0
     try:
         rect = option.rect
         rect.adjust(self.MARGIN, self.MARGIN, -self.MARGIN, -self.MARGIN)
         orect = QRect(rect)
         if cdata is None or cdata is False:
             title = db.field_for('title', book_id, default_value='')
             authors = ' & '.join(db.field_for('authors', book_id, default_value=()))
             painter.setRenderHint(QPainter.TextAntialiasing, True)
             painter.drawText(rect, Qt.AlignCenter|Qt.TextWordWrap, '%s\n\n%s' % (title, authors))
             if cdata is False:
                 self.render_queue.put(book_id)
         else:
             if self.title_height != 0:
                 trect = QRect(rect)
                 rect.setBottom(rect.bottom() - self.title_height)
             if self.animating is not None and self.animating.row() == index.row():
                 cdata = cdata.scaled(cdata.size() * self._animated_size)
             dx = max(0, int((rect.width() - cdata.width())/2.0))
             dy = max(0, rect.height() - cdata.height())
             right_adjust = dx
             rect.adjust(dx, dy, -dx, 0)
             painter.drawPixmap(rect, cdata)
             if self.title_height != 0:
                 rect = trect
                 rect.setTop(rect.bottom() - self.title_height + 5)
                 painter.setRenderHint(QPainter.TextAntialiasing, True)
                 title = db.field_for('title', book_id, default_value='')
                 metrics = painter.fontMetrics()
                 painter.drawText(rect, Qt.AlignCenter|Qt.TextSingleLine,
                                  metrics.elidedText(title, Qt.ElideRight, rect.width()))
         if marked:
             try:
                 p = self.marked_emblem
             except AttributeError:
                 p = self.marked_emblem = QPixmap(I('rating.png')).scaled(48, 48, transformMode=Qt.SmoothTransformation)
             drect = QRect(orect)
             drect.setLeft(drect.left() + right_adjust)
             drect.setRight(drect.left() + p.width())
             drect.setBottom(drect.bottom() - self.title_height)
             drect.setTop(drect.bottom() - p.height())
             painter.drawPixmap(drect, p)
         if on_device:
             try:
                 p = self.on_device_emblem
             except AttributeError:
                 p = self.on_device_emblem = QPixmap(I('ok.png')).scaled(48, 48, transformMode=Qt.SmoothTransformation)
             drect = QRect(orect)
             drect.setRight(drect.right() - right_adjust)
             drect.setBottom(drect.bottom() - self.title_height)
             drect.setTop(drect.bottom() - p.height() + 1)
             drect.setLeft(drect.right() - p.width() + 1)
             painter.drawPixmap(drect, p)
     finally:
         painter.restore()
开发者ID:shamray,项目名称:calibre,代码行数:79,代码来源:alternate_views.py


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