Results 1 to 3 of 3

Thread: TexturePattern backgroundcolour problem

  1. #1
    Join Date
    May 2011
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default TexturePattern backgroundcolour problem

    When I use a bitmap as a texture pattern, the background is not correctly displayed. When you use a build-in pattern, this is done correctly.

    The main question to solve is: Fill a figure(rectangle, cirlce, etc...) with a bitmap texturePattern and displaying the painters background and foreground colors correctly.

    I want to know if it's a bug in QT 4.7 ? or I need to set another parameter (besides the QPainter::setBackgroundMode() ) to have the correct behavour?

    A workaround to this problem would be the draw 2 times the figure, first with a solidfilled brush and second with a brush with the bitmap pattern fill.
    BUT I prefer NOT to use this option.

    Here is some code to reproduce the problem:
    Qt Code:
    1. QBitmap bitmap("debug/test.png");
    2. QBrush brushBitmap(bitmap);
    3. QRect rect(80,0,160,100);
    4. QRect rect1(0,10,150,510);
    5. QRect rect2(160,10,150,510);
    6.  
    7. painter.setBackgroundMode( Qt::OpaqueMode ); // Qt::OpaqueMode / Qt::TransparentMode
    8. painter.setBackground(QColor(0,255,0)); // Background set to green
    9. painter.setPen(QPen(Qt::black, 1, Qt::SolidLine));
    10.  
    11.  
    12. painter.fillRect(rect,QBrush(Qt::red));
    13.  
    14. painter.setBrush( brushBitmap );
    15. painter.drawRect(rect1);
    16.  
    17. painter.setBrush(QBrush(Qt::black, Qt::BDiagPattern));
    18. painter.drawRect(rect2);
    To copy to clipboard, switch view to plain text mode 

    The png:
    test.png

    Result:
    source_code_results_TransparentMode_VS_OpaqueMode.png

    Expected Result:
    Expected_results.png

    I believe its the same problem like this unresolved thread http://www.qtcentre.org/threads/3580...g-with-pattern
    Last edited by fpbosman; 10th May 2011 at 10:35.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: TexturePattern backgroundcolour problem

    Try setting different composition modes, see if it helps.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    May 2011
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: TexturePattern backgroundcolour problem

    No, unfortunately it didn't help.

    I strongly believe it's a bug in QT.

    I think the bug is located in the $QTDIR\src\gui\painting\qemulationpaintengine.cpp: 83
    Qt Code:
    1. if (style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern)
    2. real_engine->fill(path, s->bgBrush);
    To copy to clipboard, switch view to plain text mode 
    should be
    Qt Code:
    1. if ((style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern) || (style == Qt::TexturePattern ))
    2. real_engine->fill(path, s->bgBrush);
    To copy to clipboard, switch view to plain text mode 

    I will post this bug to QT bugreport system, and will wait for an answer there.

    Thx

Similar Threads

  1. QBrush TexturePattern alignment
    By Caius Aérobus in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2008, 14:41

Tags for this Thread

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.