本文整理汇总了Python中PyQt5.Qt.QTableView.setWordWrap方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.setWordWrap方法的具体用法?Python QTableView.setWordWrap怎么用?Python QTableView.setWordWrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTableView
的用法示例。
在下文中一共展示了QTableView.setWordWrap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AnnotatedBooksDialog
# 需要导入模块: from PyQt5.Qt import QTableView [as 别名]
# 或者: from PyQt5.Qt.QTableView import setWordWrap [as 别名]
#.........这里部分代码省略.........
# List order matches self.annotations_header
this_book = [
book_data['uuid'],
book_data['book_id'],
book_data['genre'],
enabled,
reader_app,
title,
author,
last_annotation,
book_data['annotations'],
confidence]
self.tabledata.append(this_book)
self.tv = QTableView(self)
self.l.addWidget(self.tv)
self.annotations_header = ['uuid', 'book_id', 'genre', '', 'Reader App', 'Title',
'Author', 'Last Annotation', 'Annotations', 'Confidence']
self.ENABLED_COL = 3
self.READER_APP_COL = 4
self.TITLE_COL = 5
self.AUTHOR_COL = 6
self.LAST_ANNOTATION_COL = 7
self.CONFIDENCE_COL = 9
columns_to_center = [8]
self.tm = MarkupTableModel(self, columns_to_center=columns_to_center)
self.tv.setModel(self.tm)
self.tv.setShowGrid(False)
self.tv.setFont(self.FONT)
self.tvSelectionModel = self.tv.selectionModel()
self.tv.setAlternatingRowColors(not self.show_confidence_colors)
self.tv.setShowGrid(False)
self.tv.setWordWrap(False)
self.tv.setSelectionBehavior(self.tv.SelectRows)
# Connect signals
self.tv.doubleClicked.connect(self.getTableRowDoubleClick)
self.tv.horizontalHeader().sectionClicked.connect(self.capture_sort_column)
# Hide the vertical self.header
self.tv.verticalHeader().setVisible(False)
# Hide uuid, book_id, genre, confidence
self.tv.hideColumn(self.annotations_header.index('uuid'))
self.tv.hideColumn(self.annotations_header.index('book_id'))
self.tv.hideColumn(self.annotations_header.index('genre'))
self.tv.hideColumn(self.annotations_header.index('Confidence'))
# Set horizontal self.header props
self.tv.horizontalHeader().setStretchLastSection(True)
narrow_columns = ['Last Annotation', 'Reader App', 'Annotations']
extra_width = 10
breathing_space = 20
# Set column width to fit contents
self.tv.resizeColumnsToContents()
perfect_width = 10 + (len(narrow_columns) * extra_width)
for i in range(3, 8):
perfect_width += self.tv.columnWidth(i) + breathing_space
self.tv.setMinimumSize(perfect_width, 100)
self.perfect_width = perfect_width
# Add some width to narrow columns
for nc in narrow_columns: