qt-interest@trolltech.com
[Top] [All Lists]

Re: [Qt-interest] emit custom built objects in signal/slot

Subject: Re: [Qt-interest] emit custom built objects in signal/slot
From: "Ulf-Alexander v. Ceumern-Lindenstjerna"
Date: Tue, 15 Sep 2009 16:32:30 +0200
Sure.

Here is what I do:

class MyClass
{
        // declare stuff ...
};

Q_DECLARE_METATYPE(MyClass);


class OtherClass
{
signals:
        void stuffHappened(MyClass);
};

// some function
void stuff
{
        MyClass l_data;
        emit stuffHappened(l_data);
}

Works like a charm.

But now, as I think about it, what about l_data lifetime? Do I need to
make sure it exists long enough?

Regards, Ulf

> -----Original Message-----
> From: qt-interest-bounces@xxxxxxxxxxxxx [mailto:qt-interest-
> bounces@xxxxxxxxxxxxx] On Behalf Of Deepak Angeshwar
> Sent: Tuesday, September 15, 2009 2:52 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: [Qt-interest] emit custom built objects in signal/slot
> 
> All,
> 
> While using QTJambi I was able to pass only primitive-data-types or a
> java.lang.Object as the argument while emitting a value via the signal
> 
> Now I am evaluating QT 4.5 (using C++), is there a way to emit user
> defined C++ object?
> 
> If I try to extend a QObject in my C++ class and emit an object of
that
> class, I get the follwoing error.
> error: `QObject::QObject(const QObject&)' is private

_______________________________________________
Qt-interest mailing list
Qt-interest@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest

<Prev in Thread] Current Thread [Next in Thread>