Hi,
I'm playing with QT library in perl6. I got it somehow working, but now I
wonder whether I'm doing it right.
QT objects are C++ classes. Roughly there is base class QObject. From that
object QWidget isderived.
class QObject;
class QWidget : public QObject;
class QAbstractButton : public QWidget;
class QPushButton : public QAbstractButton;
you get the picture.
I have represented these in p6 like:
class QObject is repr<CPPStruct> {
has Pointer $.vtable;
...
}
class QPushButton is repr<CPPStruct> is QObject {
has Pointer $.vtable;
...
}
I have skipped for now QWidget and QAbstractButton for now. It works, but:
- isn't it a problem that both classes have the $.vtable variable? QPushButton
overriding QObject one? I guess that is ok though, there's always just a
single pointer.
- I have tried to mimick GTK::Simple tap providers, but failed.
class QPushButton is repr<CPPStruct> is QObject {
has Pointer $.vtable;
has $!clicked_supply;
}
===SORRY!=== Error while compiling /home/neuron/qt/qt.pl
CPPStruct representation only handles int, num, CArray, CPointer, CStruct,
CPPStruct and CUnion
- I have tried to view QPushButton as a role to QObject
role QPushButton is repr<CPPStruct> is QObject {
# line 63:
my sub qt_QPushButton_show(QPushButton) is native('p6', v1) is
mangled(False) { * };
===SORRY!=== Error while compiling /home/neuron/qt/qt.pl
Too many positionals passed; expected 2 arguments but got 3
at /home/neuron/qt/qt.pl:63
The same for
role QPushButton is QObject {
- I have tried
class QPushButton does QObject {
===SORRY!=== Error while compiling /home/neuron/qt/qt.pl
QObject is not composable, so QPushButton cannot compose it
I have not tried making QObject a unit, is it the way to go? I'm trying to chew
on the line from GTK::Simple. I'm not sure yet what it is and how relevant it
is.
unit class GTK::Simple::Button does GTK::Simple::Widget;
Thank you
__
Vlad