I created a pushbutton in front of a video (use QVideoWidget and QMediaPlayer). I am using an image with a transparent background to set image button.
How can I set a QPushbutton to be transparent, but the image inside to be visible? I have tried setting it transparent, but the image's background turns black.
I have tried this C++ over Qt : Controlling transparency of Labels and Buttons but it doesn't work. And I tried this :
ui->btn_Touchme->setAttribute(Qt::WA_TranslucentBackground);
ui->btn_Touchme->setStyleSheet("QPushButton{background: transparent;}");
ui->btn_Touchme->setAttribute(Qt::WA_NoSystemBackground, true);
ui->btn_Touchme->setAttribute(Qt::WA_TranslucentBackground, true);
and it is still black
I tried using QLabel, but I got same result. Any suggestions for me?
I am using qt 5.3.2 and ubuntu 14.04LTS
If it is ok to show the button margin on mouse hover over the button, you can use a QToolButton
with autoRaise
set to true
.
Also, you can set following stylesheet too to make button transparent even when mouse hovers over it.
ui->btn_Touchme->setStyleSheet("background-color: rgba(255, 255, 255, 0);");