PDA

View Full Version : QPainter::drawPixmap behaves different on Windows and Linux



kshahar
9th March 2011, 16:49
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: 6060
Linux screenshot: 6061
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 -


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;
};
And the main function looks like this:


TestWidget* testWidget = new TestWidget(imagePath);
testWidget->setGeometry(0, 10, 1024, 1024);
testWidget->show();
I'm using Qt 4.5.1/4.7.2, Windows XP and CentOS 5.5.

Any ideas what could be the problem?

ChrisW67
9th March 2011, 23:50
Is one defaulting to anti-aliasing and the other not? Perhaps the difference is in the pixmap scaling options. Have you tried explicitly setting rendering settings with QPainter::setRenderHint()?

Also have a read under Rendering Quality in the QPainter docs.