Qt-interest Archive, February 2007
Subclassing and signals
Message 1 in thread
Hi,
I am wondering whether it is possible when I subclass a Qt class such
as QTcpSocket to alter the emission of signals...
What I mean is I have created a QTcpSocket subclass. When I call
connectToHost() when the socket is connected I want to perform some
actions on it before the connected() signal is emitted. How should I
be going about this? Can you change the way signals are emitted in a
subclass, or should I be reimplementing connectToHost in some way?
Any help much appreciated.
George
--
[ signature omitted ]
Message 2 in thread
> I am wondering whether it is possible when I subclass a Qt class such
> as QTcpSocket to alter the emission of signals...
Don't take my word as gospel, but I don't think so.
> What I mean is I have created a QTcpSocket subclass. When I call
> connectToHost() when the socket is connected I want to perform some
> actions on it before the connected() signal is emitted.
Just look which classes in QTcpSocket are virtual. Not that much room
to wriggle here.
> How should I
> be going about this? Can you change the way signals are emitted in a
> subclass, or should I be reimplementing connectToHost in some way?
In QObject you can block signals for an object. Maybe you can use that.
Block all signals from your QTcpSocked subclass and activate and
send signals when you want?
Guido
--
[ signature omitted ]
Message 3 in thread
Thanks for the info. I think I'll rethink how i'm doing this subclass...
On 2/8/07, Guido Seifert <wargand@xxxxxx> wrote:
>
> > I am wondering whether it is possible when I subclass a Qt class such
> > as QTcpSocket to alter the emission of signals...
>
> Don't take my word as gospel, but I don't think so.
>
> > What I mean is I have created a QTcpSocket subclass. When I call
> > connectToHost() when the socket is connected I want to perform some
> > actions on it before the connected() signal is emitted.
>
> Just look which classes in QTcpSocket are virtual. Not that much room
> to wriggle here.
>
> > How should I
> > be going about this? Can you change the way signals are emitted in a
> > subclass, or should I be reimplementing connectToHost in some way?
>
> In QObject you can block signals for an object. Maybe you can use that.
> Block all signals from your QTcpSocked subclass and activate and
> send signals when you want?
>
>
> Guido
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]