quarta-feira, 29 de julho de 2009

Using lazarus with QT widget

Screenshot:




Using lazarus with QT widget

This tip tested in Lazarus 0.9.26-2

After many attempts, I discovered with making to perfectly function (or almost) lazarus with the wonderful Qt library (version 4.5.1)
To who does not know, the QT was under license LGPL, becoming thus one of the best options of work in linux, or best.

This procedure was carried through in the ARCHLINUX

Download the archive bin-qt4pas-V1.70_Qt4.5.0.tar.gz or bin64-qt4pas-V1.70_Qt4.5.0.tar.gz .like your architecture of your pc.

to unpack:
tar - zxvf bin-qt4pas-V1.70_Qt4.5.0.tar.gz
two archives will be unpacked:
libqt4intf.so
qt4.pas

After to unpack, the archive libqt4intf.so must be copied in the following folders:
/usr/lib
/usr/lib/lazarus/lcl/interfaces/qt

Copied these archives, it enters in the /usr/lib/lazarus/lcl/interfaces/qt folder

#cd /usr/lib/lazarus/lcl/interfaces/qt

Two tasks to make in this folder:
to.rename the existing archive qt4.pas already
mv qt4.pas qt4.pas.old

to change the archive qtdefines.inc
to add the line:
{$define USE_QT_44}

After that it enters in the
/usr/lib/lazarus/lcl/units/i386/ folder and it creates a folder qt
#cd /usr/lib/lazarus/lcl/units/i386/
#mkdir qt
#chmod 0777 qt
In my case, it was not possible to compile IDE, always gave not joined error of unit
Modifying the /etc/fpc.cfg archive, it includes the following line in the section
# searchpath will be units and to other system dependent things
- Fu/usr/lib/lazarus/ideintf/

The LCL Qt has one bug in linux, does not appear the close button of form, of any form even though of IDE, what it brings a great developer discomfort.
In my case that, I decided this problem of the following mode:
.locate unit Qtwsforms.pp
.Open unit and it locates: TQtWSCustomForm.CreateHandle
Near the line 153, must appear the following code:

if not (csDesigning in TCustomForm(AWinControl).ComponentState) then
begin
UpdateWindowFlags(QtMainWindow, TCustomForm(AWinControl).BorderStyle,
TCustomForm(AWinControl).BorderIcons, TCustomForm(AWinControl).FormStyle);
end;

change to:

{$IFDEF LINUX}
UpdateWindowFlags(QtMainWindow, TCustomForm(AWinControl).BorderStyle,
[biSystemMenu,biHelp], TCustomForm(AWinControl).FormStyle);
{$ELSE}
UpdateWindowFlags(QtMainWindow, TCustomForm(AWinControl).BorderStyle,
TCustomForm(AWinControl).BorderIcons, TCustomForm(AWinControl).FormStyle);
{$ENDIF}


It saves the modifications
To compile lazarus, enters in Tools-> Build Lazarus configures


.Selects widget QT(beta)
.It marks Build All
.Click in Build
.After to conclude the compilation marks "Build IDE with Packages"
.Click in Build

If everything will right, must re-compile lazarus with widget QT, that although to have some bugs, of the much more pretty final resulted one. Soon I will be post here bugs that to find.

Best regards

2 comentários:

  1. "The LCL Qt has one bug in linux, does not appear the close button of form, of any form even though of IDE, what it brings a great developer discomfort."
    This is not a bug.
    For QT 4.5 use:
    make PREFIX=/usr clean all LCL_PLATFORM=qt OPT="-dUSE_QT_45"
    for QT 4.4.
    make PREFIX=/usr clean all LCL_PLATFORM=qt OPT="-dUSE_QT_44"
    http://users.telenet.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html

    ResponderExcluir
  2. Really, i make a compiler of lazarus subversion with latest qt4.pas e libqt4intf. Running ok.
    But in version 0.9.26 dont running, for this version my code is functional.
    Many users have dificult at compiler lazarus subversion.
    Comming soon i published my experiency in this case, here in the blog.
    Sorry m bad english ok
    Thanks

    ResponderExcluir