PyQt4 QTableWidget: Set row width and column height to fill parent widget
<p>I am working on a fairly simply PyQt program which basically is just a <code>QTableWidget</code> full of items. My goal is for the width and height of the items to automatically resize based on the size of the parent <code>QTableWidget</code>.  For example, if I resize the window smaller, the items width and height should decrease in size but there should remain the same number of items and the items should still completely fill the parent <code>QTableWidget</code>. As you see, I am currently using <code>setColumnWidth</code> and <code>setRowHeight</code> to manually set the width and height.</p>

<p>I have tried the suggestions in the following Stack Overflow questions, as well as many other questions and websites, none of which do what I am attemping to do.</p>

<p><a href="https://stackoverflow.com/questions/11839813/how-to-make-qtablewidgets-columns-assume-the-maximum-space">1. How to make qtablewidgets columns assume the maximum space</a></p>

<p><a href="https://stackoverflow.com/questions/6373033/pyqt-how-to-maximize-the-column-width-in-a-tableview">2. pyqt how to maximize the column width in a tableview</a></p>

<p>Here is the code I am using currently:</p>

<pre><code>from PyQt4 import QtGui, QtCore
import PyQt4.Qt

class Window(QtGui.QWidget):
    def __init__(self, rows, columns):
        super(Window, self).__init__()
        self.setWindowState(QtCore.Qt.WindowMaximized)
        self.table = QtGui.QTableWidget(rows, columns, self)
        self.table.verticalHeader().setVisible(False)
        self.table.horizontalHeader().setVisible(False)

        # this is what I am currently using to set the row and column size
        for x in range(columns):
            self.table.setColumnWidth(x, 13)
        for x in range(rows):
            self.table.setRowHeight(x, 13)
        for row in range(rows):
            for column in range(columns):
                item = QtGui.QTableWidgetItem()
                self.table.setItem(row, column, item)

        layout = QtGui.QGridLayout(self)
        layout.addWidget(self.table, 0, 0, 1, 6)

        self.show()


def main():
    import sys
    app = QtGui.QApplication(sys.argv)
    window = Window(54, 96)
    sys.exit(app.exec_())

if __name__ == "__main__":
    main()
</code></pre>

<p>I appoligize for the length of this question, but I wanted to make my question very clear. Thank you all in advance for your help!</p>