@Override protected void resizeEvent(QResizeEvent event) { if (width() > image.width() || height() > image.height()) { int newWidth = Math.max(width() + 128, image.width()); int newHeight = Math.max(height() + 128, image.height()); image = resizeImage(image, new QSize(newWidth, newHeight)); update(); } super.resizeEvent(event); }