[PySide] (no subject)
Bruno-Pierre Jobin
bpjobin at gmail.com
Wed May 24 21:38:15 CEST 2017
Hi all,
I want to create a footer on a TableWidget so I'm trying to stack a single
row QTableWidget (self.footer) on top of the original one (self.table).
Right now, I can see both table using the
setStackingMode(QStackedLayout.StackAll) but I'm unable to move the footer
at the bottom of self.table. Any suggestion for this?
Also, I'm pretty sure there is a cleaner way to set flags to multiple table
at once. Maybe a for loop that acts on a type of widget? Or I could also
just make a list of those two tables a itterate through that list.. I'm
thinking as I type.
Any suggestions are welcome!
Thank you
from PySide.QtGui import *
from PySide.QtCore import *
class TableWidget(QWidget):
def __init__(self):
super(TableWidget, self).__init__()
self.setMinimumSize(400, 300)
self.table = QTableWidget()
self.table.setColumnCount(2)
self.table.setRowCount(5)
self.table.setSelectionMode(QTableView.ExtendedSelection)
self.table.setSelectionBehavior(QTableView.SelectRows)
self.table.setSortingEnabled(1)
self.table.setAlternatingRowColors(True)
self.table.horizontalHeader().setStretchLastSection(True)
self.table.verticalHeader().setVisible(False)
self.table.setColumnWidth(0, 180)
self.table.horizontalHeader().setVisible(False)
self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.footer = QTableWidget()
self.footer.setRowCount(1)
self.footer.setColumnCount(2)
self.footer.setSelectionMode(QTableView.ExtendedSelection)
self.footer.setSelectionBehavior(QTableView.SelectRows)
self.footer.setSortingEnabled(1)
self.footer.setAlternatingRowColors(True)
self.footer.horizontalHeader().setStretchLastSection(True)
self.footer.verticalHeader().setVisible(False)
self.footer.setColumnWidth(0, 180)
self.footer.horizontalHeader().setVisible(False)
self.footer.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.footer.setMaximumHeight(35)
self.footer.move(0,200)
self.table_stack = QStackedLayout()
self.table_stack.addWidget(self.table)
self.table_stack.addWidget(self.footer)
self.table_stack.setStackingMode(QStackedLayout.StackAll)
self.setLayout(self.table_stack)
a = TableWidget()
a.show()
--
Bruno-Pierre Jobin
www.bpjobin.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20170524/5e32676b/attachment.html>
More information about the PySide
mailing list