I'm building a UI in Qt 5.9 that needs to run on an X11 display. I'm trying to add drop shadows to my dialog windows - but they don't work over X11.
The approach I'm taking is from zeFree's answer in This Question. (Put everything in the window in one widget, set the window translucent, and create a dropshadow effect on the widget).
setAttribute(Qt::WA_TranslucentBackground); //enable Window to be transparent
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(5);
ui->widget->setGraphicsEffect(effect);
It works great in my redhat vm:
But when I send to the X11 display I, it looks like the transparency isn't supported, and I get the shadow on black instead:
My question is: Is there a way to adjust my Qt so that running this application through an X11 display will correctly show my transparencies?
Ultimately any suggestions leading to a working drop shadow on the X11 display would be great!
To work around this problem I ended up making a shadow object on the main window using the function below. (It puts the window in the middle of the screen and builds the shadow object) Then I do ->show() and ->hide() on the shadow object when I show and hide the window. It's a bit of a cludge - but is the only solution I found that works through X11 on this particular touch screen.
QPushButton * MainWindow::positionAndShadow(QDialog* window)
{
int xpos = SCREEN_RES_H/2 - window->size().width()/2;
int ypos = SCREEN_RES_V/2 - window->size().height()/2;
if (ypos - 10 > 0)
{
ypos -= 10;
}
window->setGeometry(xpos,ypos,window->size().width(),window->size().height());
QPushButton* shadow = new QPushButton(this);
shadow->setEnabled(false);
shadow->setGeometry(xpos,ypos,window->size().width(),window->size().height());
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setColor(QColor(40, 40, 40, 220));
effect->setBlurRadius(15);
shadow->setGraphicsEffect(effect);
shadow->hide();
return shadow;
}