[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-bindings
Subject: Re: [Kde-bindings] Hacking moc-generated code
From: Luca Fascione <lukes () wetafx ! co ! nz>
Date: 2005-08-31 6:46:51
Message-ID: 4315525B.6070006 () wetafx ! co ! nz
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
I don't think static means constant across *time*, it just should mean
constant across instances of the class,
i.e. you *can* change the metaobject while it's running... :-)
And that's the way TCL/Qt will work (when I finally find the time to sit
down and actually write it).
The Qt runtime calls the metaobject stuff all the time, so I don't think
it caches the answers it gets back...
And there you go, done addition of methods at runtime: just reimplement
all the stuff with an added "addMethod()" method that will insert your
new method in some data structure and you're done.
Now, I obviously haven't tried it... :-)
My 2 cents
Luca
Eric Jardim wrote:
> 2005/8/31, Marcus <mathpup@mylinuxisp.com
> <mailto:mathpup@mylinuxisp.com>>:
>
> I would like to hear more about this because getting signals and
> slots working
> seems to be one of the hardest parts. I understand that Qt 4.x
> makes some
> changes, but I also gather that there is still a great deal of
> voodoo in the
> moc-generated code.
>
>
> Well, actually, signals and slots are working normally in python-qt4.
> I used a simple approach. I created dispatcher classes for each type
> of slot. It is impossible to connect a signal to a Python function.
> There must be a C++ slot. So I have a dispatcher class for every
> possible signature ex:
> PythonSlot_int_int -> void slot(int, int)
> and so on. Of course I have a script that write this code for me. You
> just have to say (textualy) which signatures you want to generate.
>
> It is the only way I see to make it works. The limitation of this
> approach are new types of slot signatures. Well, we can solve this
> creating a central registry for slot dispachers. Hey, remember now...
> I've made this :) But needs more testing.
>
> Returning to MOC, I just need to play with it, only because if I want
> to run Python extended classes (of QObject/QWidget) on C++ (like
> embedded C++ or using Python objects in QtDesigner). I am studing it,
> but I am not very sure that it will work.
>
> The problem is that the C++ metaobject is static. We need dynamic
> metaobjects! And that is the whole trick.
>
>
> When I have worked on schemes to interact with signals and slots,
> I have
> always been torn between using things are not part of the Qt API
> whose
> details can only be discovered by reading the files that moc
> generates OR
> writing portable but complicated, bulky code with a great deal of
> potential
> overhead. Qt goes to great lengths to make C++ less dangerous for
> programmers, but many of the techniques used make it difficult for
> non-C++
> languages to use Qt.
>
>
> Sure, but I think it is getting better. Try python-qt4 source and see
> what I did. I'll continue studing the moc files.
>
> [Eric Jardim]
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Kde-bindings mailing list
>Kde-bindings@kde.org
>https://mail.kde.org/mailman/listinfo/kde-bindings
>
>
--
Luca Fascione
Pipeline Engineer - Weta Digital
+644 380 9170 (x4855) / +64 21 0764 862
[Attachment #5 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I don't think static means constant across *time*, it just should mean
constant across instances of the class,<br>
i.e. you *can* change the metaobject while it's running... :-)<br>
<br>
And that's the way TCL/Qt will work (when I finally find the time to
sit down and actually write it).<br>
<br>
The Qt runtime calls the metaobject stuff all the time, so I don't
think it caches the answers it gets back...<br>
<br>
And there you go, done addition of methods at runtime: just reimplement
all the stuff with an added "addMethod()" method that will insert your
new method in some data structure and you're done.<br>
<br>
Now, I obviously haven't tried it... :-)<br>
<br>
My 2 cents<br>
Luca<br>
<br>
Eric Jardim wrote:
<blockquote cite="mid432ec6c50508302233514a0a43@mail.gmail.com"
type="cite">2005/8/31, Marcus <<a
href="mailto:mathpup@mylinuxisp.com">mathpup@mylinuxisp.com</a>>:
<div><span class="gmail_quote"></span>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;">I would like to hear more about this because getting signals and \
slots working<br>
seems to be one of the hardest parts. I understand that Qt 4.x makes
some<br>
changes, but I also gather that there is still a great deal of voodoo
in the
<br>
moc-generated code.</blockquote>
<div><br>
Well, actually, signals and slots are working normally in python-qt4. I
used a simple approach. I created dispatcher classes for each type of
slot. It is impossible to connect a signal to a Python function. There
must be a C++ slot. So I have a dispatcher class for every possible
signature ex:<br>
PythonSlot_int_int -> void slot(int, int)<br>
and so on. Of course I have a script that write this code for me. You
just have to say (textualy) which signatures you want to generate.<br>
<br>
It is the only way I see to make it works. The limitation of this
approach are new types of slot signatures. Well, we can solve this
creating a central registry for slot dispachers. Hey, remember now...
I've made this :) But needs more testing.<br>
</div>
Returning to MOC, I just need to play with it, only because
if I want to run Python extended classes (of QObject/QWidget) on C++
(like embedded C++ or using Python objects in QtDesigner). I am studing
it, but I am not very sure that it will work. <br>
<br>
The problem is that the C++ metaobject is static. We need dynamic
metaobjects! And that is the whole trick.<br>
<br>
<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;">When I have worked on schemes to interact with signals and slots, \
I have<br> always been torn between using things are not part of the Qt API whose
<br>
details can only be discovered by reading the files that moc generates
OR<br>
writing portable but complicated, bulky code with a great deal of
potential<br>
overhead. Qt goes to great lengths to make C++ less dangerous for
<br>
programmers, but many of the techniques used make it difficult for
non-C++<br>
languages to use Qt.<br>
</blockquote>
</div>
<br>
Sure, but I think it is getting better. Try python-qt4 source and see
what I did. I'll continue studing the moc files.<br>
<br>
[Eric Jardim]<br>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Kde-bindings mailing list
<a class="moz-txt-link-abbreviated" \
href="mailto:Kde-bindings@kde.org">Kde-bindings@kde.org</a> <a \
class="moz-txt-link-freetext" \
href="https://mail.kde.org/mailman/listinfo/kde-bindings">https://mail.kde.org/mailman/listinfo/kde-bindings</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Luca Fascione
Pipeline Engineer - Weta Digital
+644 380 9170 (x4855) / +64 21 0764 862
</pre>
</body>
</html>
_______________________________________________
Kde-bindings mailing list
Kde-bindings@kde.org
https://mail.kde.org/mailman/listinfo/kde-bindings
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic