C++ (Qt)QSizePolicy sp(QSizePolicy::Maximum,QSizePolicy::Maximum); sp.setHeightForWidth(true); setSizePolicy(sp);
int size = event->size().width(); if (event->size().height() < event->size().width()) size = event->size().height(); setGeometry(rect().x(), rect().y(), size, size);