I'm trying to draw a transparent PNG file inside a QWidget. The problem is, I'm getting different results on Windows and Linux.
Windows screenshot: screenshot-windows.jpg
Linux screenshot: screenshot-linux.jpg
The difference could be seen easily. I cannot upload the actual image because the forum breaks it, and it's not allowed to link to external websites.
The code I used for testing is -
public:
TestWidget(const char* imagePath)
{
setStyleSheet("background-color: black");
}
protected:
{
painter.
drawPixmap(QPoint(0,
0), m_pixmap
);
}
};
class TestWidget: public QWidget {
public:
TestWidget(const char* imagePath)
{
m_pixmap = QPixmap(imagePath);
setStyleSheet("background-color: black");
}
protected:
virtual void paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.drawPixmap(QPoint(0,0), m_pixmap);
}
QPixmap m_pixmap;
};
To copy to clipboard, switch view to plain text mode
And the main function looks like this:
TestWidget* testWidget = new TestWidget(imagePath);
testWidget->setGeometry(0, 10, 1024, 1024);
testWidget->show();
TestWidget* testWidget = new TestWidget(imagePath);
testWidget->setGeometry(0, 10, 1024, 1024);
testWidget->show();
To copy to clipboard, switch view to plain text mode
I'm using Qt 4.5.1/4.7.2, Windows XP and CentOS 5.5.
Any ideas what could be the problem?
Bookmarks