3 Attachment(s)
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:
Code:
QRect rect
(80,
0,
160,
100);
QRect rect1
(0,
10,
150,
510);
QRect rect2
(160,
10,
150,
510);
painter.setBackgroundMode( Qt::OpaqueMode ); // Qt::OpaqueMode / Qt::TransparentMode
painter.
setBackground(QColor(0,
255,
0));
// Background set to greenpainter.
setPen(QPen(Qt
::black,
1, Qt
::SolidLine));
painter.
fillRect(rect,
QBrush(Qt
::red));
painter.setBrush( brushBitmap );
painter.drawRect(rect1);
painter.
setBrush(QBrush(Qt
::black, Qt
::BDiagPattern));
painter.drawRect(rect2);
The png:
Attachment 6395
Result:
Attachment 6393
Expected Result:
Attachment 6394
I believe its the same problem like this unresolved thread http://www.qtcentre.org/threads/3580...g-with-pattern
Re: TexturePattern backgroundcolour problem
Try setting different composition modes, see if it helps.
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
Code:
if (style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern)
real_engine->fill(path, s->bgBrush);
should be
Code:
if ((style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern) || (style == Qt::TexturePattern ))
real_engine->fill(path, s->bgBrush);
I will post this bug to QT bugreport system, and will wait for an answer there.
Thx