2 Attachment(s)
Insert an image with transparent background on base background
Hello Everybody!
I'm a newbie of Qt. I have a problem need help. I want insert an image with transparent background (icon-home.png) in to a window which I created.
This window I set background by follow command:
Code:
window->setStyleSheet("background-image: url(./images/bg.jpg");
Image I insert by:
Code:
image
->setPixmap
(QPixmap("./images/icon-home.png"));
Then:
Code:
layout->addWidget(image);
window->setLayout(layout);
but when program run, the area transparent of image haven't color of base background (otherwise, the area stransparent of image cover base background).
How to make this area transparent dont cover base background ?
Thanks!
Re: Insert an image with transparent background on base background
Try This:
Code:
setStyleSheet("background-image: url(:/bg.jpg)");
image
->setPixmap
(QPixmap(":/icon-home.png"));
Make sure your images are available in the resource file with prefix "/".
Re: Insert an image with transparent background on base background
Re: Insert an image with transparent background on base background
hi.. how to move the image which u have inserted on the top of background. based on the certain time intervals inserted image can change the location ont he background. something like tracking of the objects/devices/systems.
Thanks in advance.
Re: Insert an image with transparent background on base background
For custom drawing , you will need to override the QWidget::paintEvent function.