qt - Fill the QLabel/QGraphics widget placed in the grid with the image -


i have placed 2 qgraphicsview's , 1 qlabel inside horizontal layout (qhboxlayout) layoutstretch set 1, 1, 1. problem when try load images inside them, images not fill widgets area. here code:

qpixmap pix1("image1.jpg"); pix1 = pix1.scaled(ui->label1->size()); ui->label1->setpixmap(pix);  qpixmap pix2("image2.jpg"); pix2 = pix2.scaled(ui->graphicsview1->size()); ui->graphicsview1->scene()->addpixmap(pix2);  qpixmap pix3("image3.jpg"); pix3 = pix3.scaled(ui->graphicsview2->size()); ui->graphicsview2->scene()->addpixmap(pix3); 

and here undesired output:

enter image description here

i have tried setting horizontalpolicy , verticalpolicy property of widget expanding , minimum, none of them helped either.

set size policy qsizepolicy::ignored , scale qt::keepaspectratiobyexpanding:

ui->label1->setsizepolicy(qsizepolicy::ignored, qsizepolicy::ignored); pix1 = pix1.scaled(ui->label1->size(), qt::keepaspectratiobyexpanding); ui->label1->setpixmap(pix); 

you want scale pixmaps in resizeevent().


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -