You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
571 B

#ifndef KEEPRATIOWIDGET_H
#define KEEPRATIOWIDGET_H
#include <QPointer>
#include <QWidget>
class KeepRatioWidget : public QWidget
{
Q_OBJECT
public:
explicit KeepRatioWidget(QWidget *parent = nullptr);
~KeepRatioWidget();
void setWidget(QWidget *w);
void setWidthHeightRatio(float widthHeightRatio);
const QSize goodSize();
protected:
void resizeEvent(QResizeEvent *event);
void adjustSubWidget();
private:
float m_widthHeightRatio = -1.0f;
QPointer<QWidget> m_subWidget;
QSize m_goodSize;
};
#endif // KEEPRATIOWIDGET_H