Ejemplo n.º 1
0
class TableWindow(QMainWindow):
    def __init__(self, title):
        super(TableWindow, self).__init__()

        # Set up the user interface from Designer.
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setWindowTitle(title)

        self.layout = QHBoxLayout(self.ui.centralwidget)
        self.ui.windowTitle = title
        self.ui.centralwidget.setLayout(self.layout)
        self.tableView = QTableView()
        self.layout.addWidget(self.tableView)
        self.tableView.setHorizontalHeader(MyHeaderView(Qt.Horizontal))
        self.tableView.setVerticalHeader(MyHeaderView(Qt.Vertical))

    def setModel(self, model):
        self.tableView.setModel(model)
        margins = self.layout.contentsMargins()
        self.resize((margins.left() + margins.right() +
                     self.tableView.frameWidth() * 2 +
                     self.tableView.verticalHeader().width() +
                     self.tableView.horizontalHeader().length()),
                    self.height())
Ejemplo n.º 2
0
class TableWindow(QMainWindow):
    def __init__(self, title):
        super(TableWindow, self).__init__()

        # Set up the user interface from Designer.
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setWindowTitle(title)

        self.layout = QHBoxLayout(self.ui.centralwidget)
        self.ui.windowTitle = title
        self.ui.centralwidget.setLayout(self.layout)
        self.tableView = QTableView()
        self.layout.addWidget(self.tableView)
        self.tableView.setHorizontalHeader(MyHeaderView(Qt.Horizontal))
        self.tableView.setVerticalHeader(MyHeaderView(Qt.Vertical))

    def setModel(self, model):
        self.tableView.setModel(model)
        margins = self.layout.contentsMargins()
        self.resize((
            margins.left() + margins.right() + self.tableView.frameWidth() * 2 + self.tableView.verticalHeader().width() + self.tableView.horizontalHeader().length()),
            self.height())