Difference between revisions of "Qt Interface"
m (→Quick start guide for Linux)
|Line 3:||Line 3:|
== Introduction ==
== Introduction ==
This interface is based on Qt 4 and
This interface is based on Qt 4 and corresponding documentation [http://doc.qt.nokia.com/ here].
Revision as of 16:10, 9 January 2012
- 1 Introduction
- 2 Other Interfaces
- 3 Quick start guide for Linux
- 4 Quick start guide for Mac OS X
- 5 Quick start guide for PDAs and Smartphones
- 6 Quick start guide for Windows
- 7 Qt 4 Bindings
- 8 Road map for the Qt 4 interface
- 9 Conditional defines accepted by the Qt Interface
- 10 Screenshots
- 11 Contributing
- 12 Mailling List
This interface is based on Qt 4 and its corresponding documentation here.
- Lazarus known issues (things that will never be fixed) - A list of interface compatibility issues
- Win32/64 Interface - The Windows API (formerly Win32 API) interface for Windows 95/98/Me/2000/XP/Vista/10, but not CE
- Windows CE Interface - For Pocket PC and Smartphones
- Carbon Interface - The Carbon 32 bit interface for macOS (deprecated; removed from macOS 10.15)
- Cocoa Interface - The Cocoa 64 bit interface for macOS
- Qt Interface - The Qt4 interface for Unixes, macOS, Windows, and Linux-based PDAs
- Qt5 Interface - The Qt5 interface for Unixes, macOS, Windows, and Linux-based PDAs
- GTK1 Interface - The gtk1 interface for Unixes, macOS (X11), Windows
- GTK2 Interface - The gtk2 interface for Unixes, macOS (X11), Windows
- GTK3 Interface - The gtk3 interface for Unixes, macOS (X11), Windows
- fpGUI Interface - Based on the fpGUI library, which is a cross-platform toolkit completely written in Object Pascal
- Custom Drawn Interface - A cross-platform LCL backend written completely in Object Pascal inside Lazarus. The Lazarus interface to Android.
Platform specific Tips
- Android Programming - For Android smartphones and tablets
- iPhone/iPod development - About using Objective Pascal to develop iOS applications
- FreeBSD Programming Tips - FreeBSD programming tips
- Linux Programming Tips - How to execute particular programming tasks in Linux
- macOS Programming Tips - Lazarus tips, useful tools, Unix commands, and more...
- WinCE Programming Tips - Using the telephone API, sending SMSes, and more...
- Windows Programming Tips - Desktop Windows programming tips
Interface 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
- LCL Internals - Some info about the inner workings of the LCL
- Cocoa Internals - Some info about the inner workings of the Cocoa widgetset
Quick start guide for Linux
As of lazarus 0.9.29 svn rev. 23858 2.1 bindings are needed, also bindings name is changed from libqt4intf to libQt4Pas !
IMPORTANT NOTE: for qt >= 4.7.XX libQt4Pas is compiled with -mstackrealign to avoid crashes, so download proper version from bindings page (binary bindings for 4.7 are marked) if your Qt version is 4.7 or higher.
The first thing to do is go to the official website of the bindings and download the binary Qt bindings. Copy the file libQt4Pas.so.5.2.1 + its symlinks libQt4Pas.so.5.2 libQt4Pas.so.5 libQt4Pas.so to the directory /usr/lib/ or /usr/local/lib Now run "ldconfig" to update the linker cache. You can verify its success by running:
ldconfig -p | grep libQt4Pas.so.5.2.1
It must say something like:
libQt4Pas.so (libc6) => /usr/local/lib/libQt4Pas.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 libQt4Pas.so* files.
Hint: If you use a Debian based distribution, you can add the following repositories to your sources.list deb http://ppa.launchpad.net/ximion/ppa/ubuntu karmic main deb-src http://ppa.launchpad.net/ximion/ppa/ubuntu karmic main (For the keys use: gpg --recv-keys 4BF17E057EC6E8C3 --keyserver http://wwwkeys.eu.pgp.net ) The repositories contain the libQt4Pas.
For Lazarus 0.9.30 and below
Now compile the LCL for Qt. First open your normal gtk2 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.
For Lazarus 0.9.31
To compile the IDE for qt, first create a backup of the lazarus executable for the case something goes wrong. Then open Tools / Configure Build Lazarus and set LCL Widget Type to qt. Then click Build. After a restart you will get the qt IDE. All projects are now compiled by default with qt.
If you use a gtk2 IDE and want to compile a project for qt, open the Project / Project Options / Build Modes. Go to Set Macro Values. Choose macro name LCLWidgetType and choose macro value to qt. Close the dialog with Ok and compile. All packages needed by your project will be automatically updated.
Installing Qt 4
Most distributions now have packages for Qt 4. 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.5.0 or superior
Known problems on linux
- glibc < 2.4 (older distros eg. FC3) users must compile qt-x11 with -no-sse or you have immediate segfaults.
Qt-4.4.1 if x11 < 7.0 & glibc < 2.4 (older distros) QPalette doesn't return good results for some palettes eg. QToolTip_palette().
Quick start guide for Mac OS X
Instructions on the Qt Interface Mac wiki page.
Quick start guide for PDAs and Smartphones
please write me
Quick start guide for Windows
There's nothing special to say for Windows, it works just like on Linux and seems less buggy than the 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 the official website http://www.qtsoftware.com/downloads/ eg. http://get.qt.nokia.com/qt/source/qt-win-opensource-4.6.3-mingw.exe, and you can download Qt4Pas5.dll from FPC Qt4 Binding. You can copy Qt4Pas5.dll in C:\windows\system32 if it isn't there, also qt4 dlls can be copied there, but maybe a better approach would be to add th QT4 bin directory into PATH. Alternatively (not tested), to not contribute to DLL hell, just copy all DLLs into the application directory.
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.
It 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.
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. (Note: Qt-4.5 and higher are now available under the LGPL license)
Step 1 - To start with download all the files needed to compile the bindings.
- Download the source code of the bindings. Go to the official website of the bindings. Link above.
- Also Download Qt 4.5.2(3) or Qt 4.6.2(3) source code for the desired platform. This is the download page: 
Step 2 - Unpack all the files you downloaded. Enter the directory where you downloaded Qt 4.5(6).2(3) source code and use this command:
run qmake -query to inspect your Qt installation qmake (creates Makefiles) make make install use make clean to clean sources directory when switching qt versions
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.5.2(3) source code. needed for old bindings.
Step 4 -
Run the script called compile_lib.bash. Now you should have a file called libqt4intf.so.5.XXXX where XXXX is version of qt bindings, and its symbolic links libqt4intf.so.5 and libqt4intf.so needed for old bindings.With new bindings you'll get libQt4Pas.so.5.2.1 and symlinks libQt4Pas.so.5.2 libQt4Pas.so.5 libQt4Pas.so which must be in your library path (eg. copy it into /usr/lib).
Road map for the Qt 4 interface
Moved here: Roadmap#Widgetset_dependent_components
Conditional defines accepted by the Qt Interface
Moved here: LCL_Defines#Qt_defines
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:
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.
There is a Lazarus - Qt mailling list for support and talk about the development of this interface here: http://lists.lazarus.freepascal.org/mailman/listinfo/qt