From a38e6014ea5441e9d29fcb3b5607cd94e4061cff Mon Sep 17 00:00:00 2001 From: Julian T Date: Wed, 16 Sep 2020 20:51:29 +0200 Subject: Scaled to fit window --- app/draw.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/draw.cpp b/app/draw.cpp index 6cbc338..88733ef 100644 --- a/app/draw.cpp +++ b/app/draw.cpp @@ -1,4 +1,5 @@ #include "draw.hpp" +#include #include #include #include @@ -12,11 +13,14 @@ DrawWidget::DrawWidget(const Config &conf) : m_drawbuffer = new QRgb[conf.m_width * conf.m_height]; m_img = QImage((uchar*)m_drawbuffer, conf.m_width, conf.m_height, QImage::Format_ARGB32); + } void DrawWidget::paintEvent(QPaintEvent*) { QPainter painter(this); - painter.drawImage(0, 0, m_img); + + auto scaled = m_img.scaled(width(), height(), Qt::KeepAspectRatio); + painter.drawImage(0, 0, scaled); } void DrawWidget::redraw() { -- cgit v1.2.3