Results 1 to 2 of 2

Thread: QPainter::drawPixmap behaves different on Windows and Linux

  1. #1
    Join Date
    Dec 2008
    Posts
    2
    Qt products
    Qt3 Qt4

    Default QPainter::drawPixmap behaves different on Windows and Linux

    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 -

    Qt Code:
    1. class TestWidget: public QWidget {
    2. public:
    3. TestWidget(const char* imagePath)
    4. {
    5. m_pixmap = QPixmap(imagePath);
    6. setStyleSheet("background-color: black");
    7. }
    8.  
    9. protected:
    10. virtual void paintEvent(QPaintEvent *)
    11. {
    12. QPainter painter(this);
    13. painter.drawPixmap(QPoint(0,0), m_pixmap);
    14. }
    15.  
    16. QPixmap m_pixmap;
    17. };
    To copy to clipboard, switch view to plain text mode 
    And the main function looks like this:

    Qt Code:
    1. TestWidget* testWidget = new TestWidget(imagePath);
    2. testWidget->setGeometry(0, 10, 1024, 1024);
    3. 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?
    Attached Images Attached Images
    Last edited by kshahar; 9th March 2011 at 16:48.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QPainter::drawPixmap behaves different on Windows and Linux

    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.

Similar Threads

  1. QPainter::drawPixmap with floats ?
    By christophe.daudin in forum Qt Programming
    Replies: 8
    Last Post: 20th October 2009, 10:19
  2. QPainter::drawPixmap always produces black on windows?
    By spbots in forum Qt Programming
    Replies: 0
    Last Post: 18th September 2009, 16:42
  3. Replies: 5
    Last Post: 7th September 2009, 20:57
  4. a runtime errors in QPainter::DrawPixmap(..)
    By richardander in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2009, 17:46
  5. Replies: 5
    Last Post: 15th January 2009, 09:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.