Hello Lazarus fans.
Im impressed by the difference of speed between GTK2 and Qt.
Here a simple example to demonstrate it.
It use 3 images (one empty and 2 loaded in project) and a timer.
The timer is set to 300 ms.
The goal is to load alternatively image2.picture or image3.picture into image1.picture with timer1.
In the project i choose 2 images (for image2 and image3) of 3 megas octets in jpg format.
Try to compile it with GTK2 (default) and then with Qt (go in Project/Project Options/Compiler Options and choose lcl Qt).
unit GTK2vsQt;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Graphics, ExtCtrls,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Image2: TImage;
Image3: TImage;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
{$if defined(lclqt)}
form1.Caption:= 'Qt slide test' ;
{$else}
form1.Caption:= 'GTK2 slide test' ;
{$ENDIF}
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
timer1.Enabled:=false;
if image1.Tag = 0 then begin
image1.Picture := image2.Picture;
image1.Tag:= 1;
end else begin
image1.Picture := image3.Picture;
image1.Tag:= 0;
end;
timer1.Enabled:=true;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.enabled := true;
end;
end.
If you compare the result with GTK2 and QT, it takes 3 seconds to load images with GTK2 and... 0,3 second with Qt.
After that test i have some questions.
- Why GTK2 is loaded by default in each Linux version i have tested (Ubuntu, Mint,...).
- Does anybody know how to easy install in a GTK2 Linux system the Qt libraries needed for a Qt-Lazarus compiled program ?
Many thanks.