本文整理汇总了Python中PySide.QtGui.QTableView.setAlternatingRowColors方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.setAlternatingRowColors方法的具体用法?Python QTableView.setAlternatingRowColors怎么用?Python QTableView.setAlternatingRowColors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QTableView
的用法示例。
在下文中一共展示了QTableView.setAlternatingRowColors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from PySide.QtGui import QTableView [as 别名]
# 或者: from PySide.QtGui.QTableView import setAlternatingRowColors [as 别名]
class MainWindow(QWidget):
def __init__(self):
QWidget.__init__(self)
self.resize(640, 480)
vbox = QVBoxLayout()
self.setWindowTitle('TableDemo')
self.setLayout(vbox)
self.table = QTableView()
self.table.setAlternatingRowColors(True)
self.table.setSortingEnabled(True)
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
cards = [Card(u'巫医', u'战吼:恢复2点生命值。', 1, 2, 1),
Card(u'狼骑兵', u'冲锋', 3, 3, 1),
Card(u'石牙野猪', u'冲锋', 1, 1, 1),
Card(u'森金持盾卫士', u'嘲讽', 4, 3, 5),
]
cardModel = CardModel(cards)
sortModel = QSortFilterProxyModel()
sortModel.setSourceModel(cardModel)
self.table.setModel(sortModel)
vbox.addWidget(self.table)
def printItem(self, idx):
print idx.model().persons[idx.row()]
示例2: _addtabondemand
# 需要导入模块: from PySide.QtGui import QTableView [as 别名]
# 或者: from PySide.QtGui.QTableView import setAlternatingRowColors [as 别名]
def _addtabondemand(self, thread):
"""Adds a new tab for the given thread, if it doesn't exist yet.
If it does, it will be made the current tab.
@param thread Instance of FourChanThreahHeader
"""
i = thread.id_()
if not i in self._openthreads.keys():
table = QTableView(self)
table.setModel(LiveFeedModel(self))
table.setAlternatingRowColors(True)
table.setEditTriggers(QAbstractItemView.NoEditTriggers)
table.setIconSize(QSize(192, 192))
table.horizontalHeader().setVisible(False)
table.horizontalHeader().setDefaultSectionSize(192)
table.horizontalHeader().setStretchLastSection(True)
table.verticalHeader().setVisible(False)
table.verticalHeader().setDefaultSectionSize(192)
table.doubleClicked.connect(self._showlivepost)
idx = self.tabPosts.addTab(table, "/%s/%s" % (thread.forum(), i))
self._openthreads[i] = (idx, thread, table)
fct = FourChanThread(
FourChanThreadUrl(thread.url()), self._masterobserver)
fct.postadded.connect(self._updatethread)
self._masterobserver.addobserver(
FourChanThreadObserver(fct, parent=self))
fct.refresh(True)
else:
idx = self._openthreads[i][0]
self.tabPosts.setCurrentIndex(idx)
示例3: MainWindow
# 需要导入模块: from PySide.QtGui import QTableView [as 别名]
# 或者: from PySide.QtGui.QTableView import setAlternatingRowColors [as 别名]
class MainWindow(QMainWindow):
def __init__(self, datta):
QMainWindow.__init__(self)
self.setWindowTitle('Project Parser')
appIcon = QIcon('search.png')
self.setWindowIcon(appIcon)
self.viewPortBL = QDesktopWidget().availableGeometry().topLeft()
self.viewPortTR = QDesktopWidget().availableGeometry().bottomRight()
self.margin = int(QDesktopWidget().availableGeometry().width()*0.1/2)
self.shirina = QDesktopWidget().availableGeometry().width() - self.margin*2
self.visota = QDesktopWidget().availableGeometry().height() - self.margin*2
self.setGeometry(self.viewPortBL.x() + self.margin, self.viewPortBL.y() + self.margin,
self.shirina, self.visota)
# statusbar
self.myStatusBar = QStatusBar()
self.setStatusBar(self.myStatusBar)
#lower long layout
self.lowerLong = QFrame()
self.detailsLabel = QLabel()
self.skillsLabel = QLabel()
self.urlLabel = QLabel()
self.locationLabel = QLabel()
self.skillsLabel.setText('skills')
self.detailsLabel.setWordWrap(True)
self.la = QVBoxLayout()
self.la.addWidget(self.detailsLabel)
self.la.addWidget(self.skillsLabel)
self.la.addWidget(self.urlLabel)
self.la.addWidget(self.locationLabel)
self.lowerLong.setLayout(self.la)
# table
self.source_model = MyTableModel(self, datta, ['Id', 'Date', 'Title'])
self.proxy_model = myTableProxy(self)
self.proxy_model.setSourceModel(self.source_model)
self.proxy_model.setDynamicSortFilter(True)
self.table_view = QTableView()
self.table_view.setModel(self.proxy_model)
self.table_view.setAlternatingRowColors(True)
self.table_view.resizeColumnsToContents()
self.table_view.resizeRowsToContents()
self.table_view.horizontalHeader().setStretchLastSection(True)
self.table_view.setSortingEnabled(True)
self.table_view.sortByColumn(2, Qt.AscendingOrder)
# events
self.selection = self.table_view.selectionModel()
self.selection.selectionChanged.connect(self.handleSelectionChanged)
#DO NOT use CreateIndex() method, use index()
index = self.proxy_model.index(0,0)
self.selection.select(index, QItemSelectionModel.Select)
self.upperLong = self.table_view
# right side widgets
self.right = QFrame()
self.la1 = QVBoxLayout()
self.btnDownload = QPushButton('Download data')
self.btnDownload.clicked.connect(self.download)
self.myButton = QPushButton('Show Skillls')
self.myButton.clicked.connect(self.showAllSkills)
self.btnSearchByWord = QPushButton('Search by word(s)')
self.btnSearchByWord.clicked.connect(self.onSearchByWord)
self.btnResetFilter= QPushButton('Discard Filter')
self.btnResetFilter.clicked.connect(self.discardFilter)
self.btnCopyURL = QPushButton('URL to Clipboard')
self.btnCopyURL.clicked.connect(self.copyToClipboard)
self.btnExit = QPushButton('Exit')
self.btnExit.clicked.connect(lambda: sys.exit())
self.dateTimeStamp = QLabel()
self.la1.addWidget(self.btnDownload)
self.la1.addSpacing(10)
self.la1.addWidget(self.myButton)
self.la1.addSpacing(10)
self.la1.addWidget(self.btnSearchByWord)
self.la1.addSpacing(10)
self.la1.addWidget(self.btnResetFilter)
self.la1.addSpacing(10)
self.la1.addWidget(self.btnCopyURL)
self.la1.addSpacing(70)
self.la1.addWidget(self.btnExit)
self.la1.addStretch(stretch=0)
self.la1.addWidget(self.dateTimeStamp)
self.right.setLayout(self.la1)
self.right.setFrameShape(QFrame.StyledPanel)
# splitters
self.horiSplit = QSplitter(Qt.Vertical)
self.horiSplit.addWidget(self.upperLong)
self.horiSplit.addWidget(self.lowerLong)
self.horiSplit.setSizes([self.visota/2, self.visota/2])
self.vertiSplit = QSplitter(Qt.Horizontal)
self.vertiSplit.addWidget(self.horiSplit)
self.vertiSplit.addWidget(self.right)
self.vertiSplit.setSizes([self.shirina*3/4, self.shirina*1/4])
self.setCentralWidget(self.vertiSplit)
self.settings = QSettings('elance.ini', QSettings.IniFormat)
self.settings.beginGroup('DATE_STAMP')
#.........这里部分代码省略.........