[Qt-interest] Fwd: A Qt-dbus question

Jeroen De Wachter Jeroen.DeWachter at elis.ugent.be
Thu Sep 2 20:00:32 CEST 2010


I overhauled your code to make it work...
I've had to change quite a bit though, so you might not recognize it :-s

I also wanted a C++ program to test it with, so I wrote my own rather
than rely on your client.py script (I'm just not familiar with Python)
My client program was written using the same methods as in the tutorial
I mentioned earlier, btw (and thus uses a generated Interface class)

Some of the stuff I had to do:

your widget class did not have the Q_OBJECT macro, which means the slot
it provides could never have been called. I added that and put the class
in a separate source file (because it just makes sense)

I needed the data type in both the adaptor and the interface
application, so I split your data definitions to a seperate file as well
(mydata.h), which is used in both programs

mydata.cpp contains the streaming operators Qt needs to
serialize/deserialize the MyData type
mydata.cpp is also used in both programs, of course...

I replaced the QArrayOfData struct with a typedef, so the default
streaming operators handle the QList<MyData> (you will see that there
are no extra streaming operators for QArrayOfData)

I added some dbus type registration calls in both the adaptor program
and the interface program

I hope this helps... and I recommend you go through that tutorial
meticulously to learn how Qt handles DBus and custom types

Kind regards,

Jeroen

On Thu, 2010-09-02 at 18:36 +0200, Thiago Macieira wrote:
> Em Quinta-feira 02 Setembro 2010, às 16:41:48, Jeroen De Wachter escreveu:
> > Hi,
> > 
> > I think you lack some streaming operators in your code...
> > Qt has no built-in way to find out how to serialize your custom MyData
> > struct.
> > 
> > You should take a look at the documentation at
> > http://doc.trolltech.com/4.6/qdbusargument.html#details
> > to see how to do add those operators
> [snip]
> 
> Jeroen is right. There's no call to qDBusRegisterMetaType anywhere in your 
> code and that's required for the type ArrayOfData to be supported.
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbus_adaptor.tar.bz2
Type: application/x-bzip-compressed-tar
Size: 4423 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100902/b7357c25/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbus_interface.tar.bz2
Type: application/x-bzip-compressed-tar
Size: 5405 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100902/b7357c25/attachment-0001.bin 


More information about the Qt-interest-old mailing list