quarta-feira, 29 de julho de 2009

Usando o lazarus com QT widget

(English Version at the end of page)

Esta dica esta obsoleta. A partir da versão 0.9.28 a Qt vem configurada perfeitamente.

Apos varias tentativas, descobri com fazer funcionar perfeitamente(ou quase) o lazarus com a maravilhosa biblioteca Qt (versao 4.5.1)

Screenshot:




Pra quem não sabe, a QT foi disponibilizada sob a licença LGPL, tornando-se assim uma das melhores opções de trabalho no linux, senão a melhor.

Esse procedimento foi realizado no ARCHLINUX

.Baixar o arquivo
bin-qt4pas-V1.70_Qt4.5.0.tar.gz ou
bin64-qt4pas-V1.70_Qt4.5.0.tar.gz
..dependendo da arquitetura da maquina

descompactar:
tar -zxvf bin-qt4pas-V1.70_Qt4.5.0.tar.gz

dois arquivos serão descompactados:
libqt4intf.so
qt4.pas

Após descompactar, o arquivo libqt4intf.so deve ser copiado nas seguintes pastas:
/usr/lib
/usr/lib/lazarus/lcl/interfaces/qt

Copiados esses arquivos, entre na pasta /usr/lib/lazarus/lcl/interfaces/qt

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

Duas tarefas a fazer nessa pasta:
.renomear o arquivo qt4.pas ja existente
mv qt4.pas qt4.pas.old

.alterar o arquivo qtdefines.inc
acrescentar a linha:
{$define USE_QT_44}

Em seguida entre na pasta /usr/lib/lazarus/lcl/units/i386/ e crie uma pasta qt

#cd /usr/lib/lazarus/lcl/units/i386/
mkdir qt
chmod 0777 qt

Na minha maquina, não era possivel compilar a ide, sempre dava erro de unit não encontrada

Alterando o arquivo /etc/fpc.cfg, inclui a seguinte linha na seção
# searchpath for units and other system dependent things
-Fu/usr/lib/lazarus/ideintf/

A LCL Qt tem um bug no linux, não aparece o botão fechar do form, de qualquer form até mesmo da ide, o que traz um grande desconforto pro desenvolvedor.
No meu caso, resolvi esse problema da seguinte forma:

Localize a unit qtwsforms.pp

Abra a unit e localize: TQtWSCustomForm.CreateHandle

Apartir da linha 153, deve aparecer o seguinte codigo:

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

altere para:

{$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}

.Salve as modificações

Pra recompilar o lazarus, entre em Tools->Configure Build Lazarus
Marque Build All
Selecione o widget qt (beta)
Clique em Build

Após concluir a compilação
marque Build IDE with Packages
Clique em Build

Se tudo tiver certinho, deve recompilar o lazarus com o widget QT, que apesar de ter alguns bugs, dá um resultado final muito mais bonito.
Em breve estarei postando aqui os bugs que eu encontrar

Até a próxima

English Version

Using lazarus with QT widget

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