Forum > QT

[qt5] unexpected result after FillRect when pen style is psPattern

(1/1)

Valdas:
Code to try (FormPaint event):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormPaint(Sender: TObject);const  RASTAS__TASKELIAI_1_1: TPenPattern = (5, 5);begin    color := clWhite;    with Canvas do begin        Pen.Cosmetic := TRUE;        Pen.Width := 1;         Pen.Color := clRed;         Brush.Color := clSkyBlue;         FillRect(0, 0, 50, 50); // <----- this         Brush.Style := bsClear; // no effect        Brush.Color := clNone; // no effect         Pen.Style := psPattern;        Pen.SetPattern(RASTAS__TASKELIAI_1_1);         Line(0, 100, 100, 100);    end;end; When FillRect is commented out (first attachment) I get only red dashed line as expected.
When FillRect is active then I get dashed line with brush.color dashes in between the red dashes.

In Gtk2 widgetset I always get red dashed line as expected.

Is this a bug or does this only happen on my system?

---------
Lazarus 2.3.0 (rev main-2_3-2889-g1b9d3d4cbf) FPC 3.2.2 x86_64-linux-gtk2
qt5 v5.15.8
yay qt5pas: 1 community/qt5pas 2.6.2.2.4-1 (479.3 KiB 2.3 MiB) (Installed: 2.6.main-1)

zeljko:
I can confirm your observation on Qt, Qt5 and Qt6 under X11. Please open bug report and attach example project.

zeljko:
Workaround:
...
      SaveHandleState; {<-------  add this}
      Brush.Color := clSkyBlue;

      FillRect(0, 0, 50, 50); // <----- this
      RestoreHandleState; {<------- add this}

Valdas:
Reported: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40165.

zeljko:
Thanks, better workaround is to call
LCLIntf.SetBkColor(Handle, clNone);
instead of Brush.Color := clNone, or if you call
Brush.Style := bsClear or Brush.Color := clNone call
Canvas.GetUpdatedHandle([csBrushValid]); after.

Navigation

[0] Message Index

Go to full version