0

Perhaps there is a better way to phrase the question but thats the best i could think of at the moment. Anyways the problem is this.

I have a PNG file to uses as a QMainWindow background and i am setting it using Stylesheets. Only problem is to give a rounded corner i have used an alpha channel in the png file.

The channel is transparent but underneath it I am seeing grey color (instead of being transparent) thanks to QMainWindow. I tried setting the background to transparent in the stylesheet itself but then it became black.

I am setting it via the method as specified below.

void MainWindow::setBackgroundImage(QString file)
{
    QString sheet = QString("MainWindow {border-image:url(%1); }").arg(file);
    this->setStyleSheet(sheet);
}

(I tried using background-image but it does not fit to contents so i am using border-image tag instead). Anyone have any idea how i can make the area of the alpha channel appear transparent?

Jiju Paul
  • 13
  • 5
  • Maybe it's related to [this](http://stackoverflow.com/questions/9569451/transparent-splashscreen-picture-qt)? It's an old post - depends on the version you're using. – Son-Huy Pham Jul 08 '13 at 15:55
  • Am I correct in assuming that you want your main window to appear to be the shape of your background image? So no frame, etc... – Liz Jul 08 '13 at 16:05

1 Answers1

-1

you should also set:

QMainWindow::setAttribute(Qt::WA_TranslucentBackground, true);
Beryllium
  • 12,808
  • 10
  • 56
  • 86
programtg
  • 133
  • 1
  • 5