How to stretch the background image to the entire size of the widget? With the addition described below, the upper left corner of the image is “pulled out”. And it is necessary to stretch it in proportion to the size of the widget. Is it possible to do this without resorting to CSS?

class WidgetLoading: public QWidget { private: QBrush *brush; QPalette *palette; QImage *image; public: WidgetLoading(); ~WidgetLoading(); }; WidgetLoading::WidgetLoading(): QWidget() { brush = new QBrush; palette = new QPalette; image = new QImage(":/fon.jpg"); this->setAutoFillBackground(true); brush->setTextureImage(*image); palette->setBrush(QPalette::Window, *brush); this->setPalette(*palette); } WidgetLoading::~WidgetLoading() { delete brush; delete palette; delete image; } 

    1 answer 1

    Use QImage::resized()

    • QImage :: scaled (). Watching what version - Alexey Kotov