NAME
QObject - Interface to the Qt QObject class
SYNOPSIS
use QObject;
use signals 'sig1()', ..., 'sigx(int)';
use slots 'slot1()', ..., 'sigx(int,int)';
Member functions
new, blockSignals, className, connect, disconnect, dumpObjectInfo, dumpObjectTree, event, eventFilter, highPriority, inherits, insertChild, installEventFilter, isA, isWidgetType, killTimer, killTimers, name, removeChild, removeEventFilter, setName, signalsBlocked, startTimer
Virtual functions
timerEvent
DESCRIPTION
Except for children() and queryList(), every public QObject member-function is fully-implemented. Unless noted below, all of those functions are completely direct interfaces.
- $connected = $reciever->connect(sender, signal, member)
-
Do NOT attempt to use SIGNAL() or SLOT() on the signal and member arguments. They are not needed by PerlQt, because the connect() function can automatically determine whether the member argument is a signal or a slot, and the signal will always be a signal. The signal and member arguments must be strings. And at the moment, there isn't much room for error.
- $connected = QObject::connect(sender, signal, reciever, member)
-
Same as above listing, just as a normal function with a different argument-list.
- $disconnected = $sender->disconnect(signal = undef, reciever = undef, member = undef)
-
Remember NOT to use SIGNAL() and SLOT() with disconnect(). This function takes over for both the static disconnect() and the 3-arg member disconnect() in Qt.
- $disconnected = $sender->disconnect(reciever, member = undef)
-
Same warning about SIGNAL() and SLOT() as above.
- timerEvent(event)
-
This is a virtual function, meant to be reimplemented in your own classes. It is currently available through QObject and QWidget.
Signals and slots
Signals and slots are implemented in a limited way at the moment. You may use no-arg signals and slots freely, as well as 1 and 2 integer argument signals and slots.
The declaration of signals and slots is done through the usage of 'use signals' and 'use slots'. Any classes which have QObject in their inheritance tree are free to use signals/slots after their superclass has been included via require/use.
- use signals 'sig1()', ..., 'sigx(int,int)'
-
The arguments to
use signals
must be strings representing the signal prototypes excluding the object parameter. You may useqw()
to quote the function prototypes, but it warns about commas when -w is in use.Add spaces at your own risk. Misspell at your own risk. PerlQt doesn't do any error-checking yet. All error-checking that is done is done by Qt. You may run
use signals
as many times as you want. I'm pretty sure that if you define the same signal-name twice, the latter prototype is used. But you should get a redefined function warning. Also, the argument-types are not checked yet.Running
use signals
exports a function namedemit
into your namespace. It does nothing, and is just there for clarity and consistency with Qt where the emit keyword is just as void. When you emit a signal, you must call it as a method-call$self->signal()
, and not as'signal()'
orsignal()
because it is not a string and it is not a normal function. - use slots 'slot1()', ..., 'slotx(int)'
-
The arguments to
use slots
must be strings representing the prototypes of the slots you want to declare excluding the object parameter. The slot functions aren't cached by PerlQt, and are always called as full method-calls.Once you declare a function as being a slot, you may use connect() to connect any signal, Perl or C++, to it.
BUGS
Signals and slots are seriously crippled. They do not check their arguments, they only allow a couple of integer only arguments, and there's a serious memory-leak which I can only attribute to signals and slots or to virtual member-function overrides. At the moment, PerlQt signals and slots are little more than proof-of-concept and it will take significant effort to get it working right. Any suggestions are welcome.
SEE ALSO
QObject(3qt), QGlobal(3)
AUTHOR
Ashley Winters <jql@accessone.com>