Search code examples
qtqtgui

Is there a simple way to restore widget sizes in Qt?


I'm looking for a way to preserve the size of windows in a Qt app.

I've seen that there is the possibility of using the following method for every widget:

saveGeometry()

But really, I don't find this a satisfactioning method. Is there something like setAutosaveGeometry(True)?

I'm especially looking for a way to store the widths of table columns.


Solution

  • The QHeaderView class also has two methods for saving and restoring it's state to and from a QByteArray: saveState()and restoreState()

    A table view's headers are accessible via the horizontalHeader() and verticalHeader() methods.