Recent

Author Topic: [qt5] unexpected result after FillRect when pen style is psPattern  (Read 1225 times)

Valdas

  • New Member
  • *
  • Posts: 49
Code to try (FormPaint event):
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormPaint(Sender: TObject);
  2. const
  3.   RASTAS__TASKELIAI_1_1: TPenPattern = (5, 5);
  4. begin
  5.     color := clWhite;
  6.     with Canvas do begin
  7.         Pen.Cosmetic := TRUE;
  8.         Pen.Width := 1;
  9.  
  10.         Pen.Color := clRed;
  11.  
  12.         Brush.Color := clSkyBlue;
  13.  
  14.         FillRect(0, 0, 50, 50); // <----- this
  15.  
  16.         Brush.Style := bsClear; // no effect
  17.         Brush.Color := clNone; // no effect
  18.  
  19.         Pen.Style := psPattern;
  20.         Pen.SetPattern(RASTAS__TASKELIAI_1_1);
  21.  
  22.         Line(0, 100, 100, 100);
  23.     end;
  24. end;
  25.  
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

  • Hero Member
  • *****
  • Posts: 1718
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: [qt5] unexpected result after FillRect when pen style is psPattern
« Reply #1 on: March 14, 2023, 11:22:41 am »
I can confirm your observation on Qt, Qt5 and Qt6 under X11. Please open bug report and attach example project.

zeljko

  • Hero Member
  • *****
  • Posts: 1718
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: [qt5] unexpected result after FillRect when pen style is psPattern
« Reply #2 on: March 14, 2023, 11:39:09 am »
Workaround:
...
      SaveHandleState; {<-------  add this}
      Brush.Color := clSkyBlue;

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



zeljko

  • Hero Member
  • *****
  • Posts: 1718
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: [qt5] unexpected result after FillRect when pen style is psPattern
« Reply #4 on: March 14, 2023, 04:32:27 pm »
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.

 

TinyPortal © 2005-2018