Adjust an SVG image to qlabel
I have created my application, I created a label that should show an SVG image from a file, so far, I have been able to make it to show the image, but it is neither centered nor size adjusted, I tried the following code but it did nothing:
QPixmap pix("imagelocation.svg"); int w = ui->label_pic->width(); int h = ui->label_pic->height(); ui->label_pic->setPixmap(pix.scaled(w,h,Qt::KeepAspectRatio));
Can someone help me please?
When and where are you calling that code ?
Im calling the code after creating this img by pressing a button, another problem Im facing iz that when I press the button I cant see changes till I drag (expand) the window borders, could this has something to do?
You need to provide a bit more context. A minimal compilable example would be best with also a sample svg file that triggers this.
By the way, which version of Qt are you using ? On what platform ?