Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2008-02

WidgetSet.AddEventHandler and friends

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ales Katona

I'm trying to implement WidgetSet.AddEventHandler and friends for Qt4 widgetset so I can integrate lNet into the main loop of qt4 (make it watch my sockets).

Now, I've found out QSocketNotifier at
http://doc.trolltech.com/4.3/qsocketnotifier.htmlhttp://doc.trolltech.com/4.3/qsocketnotifier.html but I'm a bit confused about 2 things:

1. How is the QSocketNotifier tied to the qt main loop? (no need to register it? is it internally done?)

2. How to handle the "activated" signal? AFAIK adding handlers for these requires a C++ method?

Thanks,

Ales

zeljko
to Ales Katona
Ales Katona wrote 13 lines
I'm trying to implement WidgetSet.AddEventHandler and friends for Qt4 widgetset so I can integrate lNet into the main loop of qt4 (make it watch my sockets). Now, I've found out QSocketNotifier at http://doc.trolltech.com/4.3/qsocketnotifier.htmlhttp://doc.trolltech.com/4 .3/qsocketnotifier.html but I'm a bit confused about 2 things: 1. How is the QSocketNotifier tied to the qt main loop? (no need to register it? is it internally done?) 2. How to handle the "activated" signal? AFAIK adding handlers for these requires a C++ method?

Look at QEvent documentation:
QEvent::SockAct 50 Socket activated, used to implement QSocketNotifier.

Show quoted text 7 lines
Thanks, Ales _______________________________________________ Qt mailing list http://www.lazarus.freepascal.org/mailman/listinfo/qt
Ales Katona
to zeljko

zeljko wrote / nap?sal(a):

Show quoted text 7 lines
Look at QEvent documentation: QEvent::SockAct 50 Socket activated, used to implement QSocketNotifier.

Ok so if I understand this right, I need to create a subclass of QEvent, implement the functionality of "callback" into the SubClass::event() and then somehow get that class exported via the qt4pas interface?

Ales

zeljko
to Ales Katona
Ales Katona wrote 7 lines
zeljko wrote / nap?sal(a): > Look at QEvent documentation: > QEvent::SockAct 50 Socket activated, used to implement QSocketNotifier. Ok so if I understand this right, I need to create a subclass of QEvent, implement the functionality of "callback" into the SubClass::event() and then somehow get that class exported via the qt4pas interface?

You have also QAbstractSocket for implementing common sockets ? What is INet ? if you really need QSocketNotifier and listen read,write, exception events then I'm not sure if U need to subclass it. You can override default EventFilter and add SockAct event, then check when socket was activated on Sender parameter of EventFilter (Sender should be the parent of QSocketNotifier).
For each QSocketNotifier type you have to create it's own instance so for read & write you have to create 2 QSocketNotifiers.

Anyway, this is my wild guess since I've never used QSocketNotifier in this life :)

Ales Katona
to zeljko

zeljko wrote / nap?sal(a):

You have also QAbstractSocket for implementing common sockets ?

Useless for this purpose.

Show quoted text 12 lines
What is INet ? if you really need QSocketNotifier and listen read,write, exception events then I'm not sure if U need to subclass it. You can override default EventFilter and add SockAct event, then check when socket was activated on Sender parameter of EventFilter (Sender should be the parent of QSocketNotifier). For each QSocketNotifier type you have to create it's own instance so for read & write you have to create 2 QSocketNotifiers. Anyway, this is my wild guess since I've never used QSocketNotifier in this life :)

LNet is a networking library. This is however not useful only for that. The AddEventHandler functions should be implemented for all widgetsets.

Ales