Perl is a powerful and versatile high-level programming language. You can find out more about the language itself on the Perl website.
Complete object-oriented bindings for Qt 3, based on SMOKE, are available on the PerlQt project page. Those bindings provide virtual functions overloading, custom slots and signals, and Rapid Application Development (RAD) through puic, a Qt Designer compatible user interface compiler.
The Qt 3 bindings have been ported to work with Qt 4, and is included with the kdebindings module for KDE SC 4.5. The rest of this document supplies information about these bindings.
#!/usr/bin/perl use strict; use warnings; use QtCore4; use QtGui4; my $app = Qt::Application( \@ARGV ); my $hello = Qt::Label( 'Hello, World!' ); $hello->show(); exit $app->exec(); </code> = API Overview = The PerlQt4 API mimics PerlQt3 very closely. So if you have written using PerlQt3, the transition should be very easy. == Coverage == PerlQt4 is modular, where one Perl module will load one Qt/KDE module. Modules currently exist for: === Qt === *QtCore *QtGui *QtDBus *QtNetwork *QtTest *QtXml === KDE === *KDECore *KDEUi *KIO *Plasma == Available methods == All Qt public and protected methods are supported, as well as friend methods. == Virtual Methods == All virtual methods can be overridden by Perl subroutines. == Properties == Some classes in Qt are implemented using publicly accessible properties, like the QStyleOption classes. To set properties, call a method called "set<PropertyName>", like <syntaxhighlight lang="perl"> $styleOption->setDirection(); </code> == Operator overloading == The full range of Qt operator methods is available, for example: <syntaxhighlight lang="perl"> my $p1 = Qt::Point(5,5) # (5, 5) my $p2 = Qt::Point(20,20) # (20, 20) $p1 + $p2 # (25, 25) </code> == Subclassing == To define a subclass, declare a package, and then use the "QtCore4::isa" module. Pass the name of the class you're subclassing as an argument, similar to the syntax for "use base". <syntaxhighlight lang="perl"> package MyWidget; use QtCore4; use QtCore4::isa qw( Qt::Widget ); </code> == Signals and Slots == Signals and slots are declared by use'ing the QtCore4::signals and QtCore4::slots modules. The arguments is an array of string/arrayref pairs, where the items in the array define the types of arguments that signal/slot accepts. In the background, it is building a C++ method signature. [[Category:Perl]]