How to make QGridLayout adaptive to the size of the window, so that when I resize it, the amount of cols and rows would change automatically?
That sounds more like a "flow layout", not a grid layout. So no, I don't think QGridLayout
can do that. And there's no predefined FlowLayout class in qt. BUT: I found this via google:
http://doc.qt.io/qt-5/qtwidgets-layouts-flowlayout-example.html
That looks like a semi-official flow-layout implementation.