Recent

Author Topic: [solved]canvas painting not work on qt  (Read 3989 times)

ali-libre

  • New Member
  • *
  • Posts: 40
[solved]canvas painting not work on qt
« on: October 10, 2016, 04:05:06 pm »
i'm try paintint on form using qt but nothing happend
it seem's canvas have problem on qt...
« Last Edit: October 10, 2016, 05:45:51 pm by ali-libre »

wp

  • Hero Member
  • *****
  • Posts: 7551
Re: canvas painting not work on qt
« Reply #1 on: October 10, 2016, 04:18:09 pm »
it seem's canvas have problem on qt...
Certainly not. What are you doing?

This code is working in Linux Mint/qt:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     procedure FormPaint(Sender: TObject);
  16.   private
  17.  
  18.   public
  19.  
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.lfm}
  28.  
  29. { TForm1 }
  30.  
  31. procedure TForm1.FormPaint(Sender: TObject);
  32. begin
  33.   Canvas.Brush.Color := clRed;
  34.   Canvas.Ellipse(10, 10, Width-10, Height-10);
  35. end;
  36.  
  37. end.  
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

ali-libre

  • New Member
  • *
  • Posts: 40
Re: canvas painting not work on qt
« Reply #2 on: October 10, 2016, 04:23:37 pm »
no.  not worked...
what goes wrong...?

lainz

  • Hero Member
  • *****
  • Posts: 3709
  • Leandro Diaz
Re: canvas painting not work on qt
« Reply #3 on: October 10, 2016, 04:27:22 pm »
no.  not worked...
what goes wrong...?

You clicked in the Object Inspector, then in 'Events' tab, and then click on OnPaint event to create the event?

ali-libre

  • New Member
  • *
  • Posts: 40
Re: canvas painting not work on qt
« Reply #4 on: October 10, 2016, 04:45:46 pm »
no means not painted...
it compile and run without any error or fault
but not red form

lainz

  • Hero Member
  • *****
  • Posts: 3709
  • Leandro Diaz
Re: canvas painting not work on qt
« Reply #5 on: October 10, 2016, 04:59:22 pm »
no means not painted...
it compile and run without any error or fault
but not red form

I know. But you didn't answer my question.

wp

  • Hero Member
  • *****
  • Posts: 7551
Re: canvas painting not work on qt
« Reply #6 on: October 10, 2016, 05:23:10 pm »
In the attachment you find the full project of which I had shown only the pas file. Unzip, compile and run. It must work.

Select the form in the Object inspector, select the second page "Events". See the "FormPaint" next to "OnPaint"? This means that the OnPaint event of the form has been assigned to the code in the procedure "FormCreate". To create such an assignment in case of a new project you select the line with "OnPaint" and click on the '...' button (or double-click on the white space). This opens the code editor and inserts an empty event method. Now you can add the drawing code that you want.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

lainz

  • Hero Member
  • *****
  • Posts: 3709
  • Leandro Diaz
Re: canvas painting not work on qt
« Reply #7 on: October 10, 2016, 05:37:25 pm »
ali-libre

You get where is the object inspector? I asked you before but you didn't answer what language you speak, maybe if your lazarus isn't in english due to translations you can't get what we're talking here. Is just my idea, I don't know. Try to change lazarus language to english, I did that to get what everyone else is talking here. Then when you know it, you can change it back to your native language.

I know english can be hard for non native speakers, like me (I speak and write in spanish), but you need to get it else is difficult to get help here and in general in programming, everything is in english.
« Last Edit: October 10, 2016, 05:39:53 pm by lainz »

ali-libre

  • New Member
  • *
  • Posts: 40
Re: canvas painting not work on qt
« Reply #8 on: October 10, 2016, 05:45:01 pm »
i'm sorry
i have to do something and it become late
yes you right..
canvas worked truly
i was edited bgrabitmap mounth ago to work on qt but it wasn't
now restore bgrabitmap
canvas work without any problem...
i must to listen than speak
thank's
« Last Edit: October 10, 2016, 05:58:42 pm by ali-libre »

 

TinyPortal © 2005-2018