Qt Interface
From Lazarus-ccr
English (en) Français (fr) Japanese (ja)
[edit] Introduction
The Qt 4 widgetset is under of development.
This interface is based on Qt 4 and it's corresponding documentation here.
[edit] Other Interfaces
- Lazarus known issues (things that will never be fixed) - A list of interface compatibility issues
- Win32/64 Interface - The winapi interface for Windows 95/98/Me/2K/XP/Vista, but not CE
- GTK1 Interface - The gtk1 for Unixes, Mac OS X, Windows
- GTK2 Interface - The gtk2 for Unixes, Mac OS X, Windows
- Carbon Interface - The Carbon Interface for Mac OS X
- Qt Interface - The Qt 4 Interface for Unixes, Mac OS X and linux-based PDAs
- Windows CE Interface - For Pocket PC and Smartphones
- fpGUI Interface - A widgetset completely written in Object Pascal
- Cocoa Interface - The Cocoa Interface for Mac OS X
[edit] Platform specific Tips
- OS X Programming Tips - Lazarus installation, useful tools, Unix commands, and more...
- WinCE Programming Tips - Using the telephone API, sending SMSes, and more...
- Windows Programming Tips - Desktop Windows programming tips.
[edit] Interfaces Development Articles
- Carbon interface internals - If you want to help improving the Carbon interface
- Windows CE Development Notes - For Pocket PC and Smartphones
- Adding a new interface - How to add a new widget set interface
- LCL Defines - Choosing the right options to recompile LCL
[edit] Quick start guide for Linux
The first thing to do is go to the official website of the bindings and download the binary Qt bindings. Copy the file libqt4intf.so to the directory /usr/local/lib/ Now run "ldconfig" to update the linker cache. You can verify its success by running:
ldconfig -p | grep libqt4intf
It must say something like:
libqt4intf.so (libc6) => /usr/local/lib/libqt4intf.so
If it didn't work, you have to check the config files in /etc/ld.so.conf.d/ or the config file /etc/ld.so.conf, depending on your distro - it must include the path where you copied the libqt4intf.so file.
Now compile the LCL for Qt. First open your normal gtk compiled Lazarus. Then go on the menu "Tools" --> "Configure Build Lazarus". Set LCL to "clean+build" and everything else to "None". Now select "Qt" and click on the "Ok" button. Next go to the menu "Tools" --> "Build Lazarus". Now the LCL is compiled for Qt.
To compile a project for Qt just select it as the target widgetset on the Compiler Options dialog.
At this moment the Lazarus IDE cannot be compiled for Qt because it uses features missing on this widgetset.
Installing Qt 4
Qt 4 is very new, so many distributions don´t come with it by default. If your distribution is RPM-based you can search for a qt4 package here: http://rpm.pbone.net/index.php3/stat/2/simple/2
The supported Qt version is 4.3.0 or superior
[edit] Quick start guide for Mac OS X
Instructions on the Qt Interface Mac wiki page.
[edit] Quick start guide for PDAs and Smartphones
please write me
[edit] Quick start guide for Windows
There's nothing special to say for windows, it works just like on Linux, and seem less buggy than win32 interface with some controls (TListView). Just rebuild Lazarus as it is mentioned for Linux , change to qt in compiler options and that's it.
Installing Qt 4
Download qt4 opensource edition from Trolltech website (http://trolltech.com/developer/downloads/qt/windows)
[edit] Qt 4 Bindings
This interface utilizes Qt 4 bindings created by Den Jean. The bindings are a c++ library which exports the methods of the Qt objects as procedures. The library (around 800kb in Linux) consists of a single .so file that needs to be distributed with your LCL program.
You can find more information about those bindings on the official website and on fpc:Qt4 binding.
Is is being reported that it may be possible to link to Qt 4 directly, using some tricks. Many think it is not. This is yet to be tested. It is expected that any such binding will be compatible with the currently utilized one, so the interface code won´t have to be changed.
[edit] Compiling the bindings
It is not necessary to compile the bindings yourself if you plan to release a GPL software. GPL Binaries are available on Den Jean website. If you want to release non-GPL code, then you must compile the bindings yourself using the Commercial Edition of Qt.
Step 1 - To start with download all the files needed to compile the bindings.
- Download the source code of the bindings. Go to the offical website of the bindings. Link above.
- Also Download Qt 4.3.0 source code for the desired platform. This is the download page: [1]
Step 2 - Unpack all the files you downloaded. Enter the directory where you downloaded Qt 4.3.0 source code and use this command:
./configure make
Step 3 - Go to the directory where you downloaded and extracted qt4pas sources and edit the file compile_lib.bash. Change the path for the Qt 4.3.0 source code.
Step 4 - Run the script called compile_lib.bash. Now you should have a file called libqt4intf.so
[edit] Road map for the Qt 4 interface
Moved here: Roadmap#Widgetset_dependent_components
[edit] Conditional defines accepted by the Qt Interface
Moved here: LCL_Defines#Qt_defines
[edit] Screenshots
More screenshoots
Qt Lazarus IDE running under linux (kernel 2.6.12, XOrg-6.8.2, KDE-3.4.0)
Qt Lazarus IDE running under MacOSX 10.4.10
[edit] Contributing
[edit] How to add a new control
For example TButton.
TButton is defined in lcl/buttons.pp. This is the platform independent part of the LCL, which is used by the normal LCL programmer.
Its widgetset class is in lcl/widgetset/wsbuttons.pp. This is the platform independent base for all widgetsets (qt, carbon, gtk, win32, ...).
Its qt interface class is in lcl/interfaces/qt/qtwsbuttons.pp:
TQtWSButton = class(TWSButton) private protected public class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; end;
Every WS class, that actually implements something must be registered. See the initialization section at the end of the qtwsXXX.pp unit:
RegisterWSComponent(TQtButton, TQtWSButton);
TQtWSButton overrides CreateHandle to create a qt QPushButton. The code is short and should be easily adaptable for other controls like TCheckBox. Remember that all controls on the Qt widgetset have a helper class on qtprivate.pp, and it is also necessary to add a class for the new control. This isn´t difficult.
Also notice that DestroyHandle should be implemented to clean up memory utilized by the control.
[edit] Mailling List
There is a Lazarus - Qt mailling list for support and talk about the development of this interface here: http://www.lazarus.freepascal.org/mailman/listinfo/qt

