[Qt] FPC Qt4 Binding V1.39
zeljko
zeljko at holobit.net
Wed Jul 4 09:44:27 CEST 2007
On Wednesday 04 July 2007 01:49, Den Jean wrote:
> 3) Override Method CloseEvent for QWidget,QMainwindow,QMdiSubWindow:
> ===============================================
> In general this binding lacks the possibilty to override methods. But
> the Borland binding was not different and allowed to create CLX. For the
> goal of this binding (LCL) this is therefore acceptable. For direct
> programming it is not great. But for a widget interface it is fine.
> In this binding you need to create eventhandlers/filters to override
> event behaviour.
>
> There was already a demo of this for the paint method. I have added one
> for the CloseEvent stuff to make this clear. See demo Mainwindow
> CloseQuery
No, Den it cannot work since we don't have anything like that in our qt-lcl
code. There's call to SlotClose() (which sends message to LCL) and that's it.
I didn't found any way how to catch some result from SlotClose().
This is what trolltech says about QWidget::closeEvent():
QWidget::close()
First it sends the widget a QCloseEvent. The widget is hidden if it accepts
the close event. If it ignores the event, nothing happens. The default
implementation of QWidget::closeEvent() accepts the close event.
QWidget::closeEvent ()
This event handler, for event event, can be reimplemented in a subclass to
receive widget close events.
I've tested all solutions (maybe there's better but didn't found any), but
only QWidgetHack (or we can call it QWidgetLCL) works ok.
Also it can be added as separate constructor (QWidget_createLCL()), so it will
not harm any, and we can test code with or without overriden closeEvent().
How to reproduce:
Create application in Lazarus, assign OnCloseEvent() and put some code there,
try to close application. If you answer Yes, application should close, if you
say No it also closes ;)
Before this you should add small patch into TQtWidget.EventFilter();
QEvent_accept(Event) should be
if QEvent_type(Event) <> QEventClose then
QEvent_accept(Event)
and QEventClose: SlotClose;
change to
QEventClose:
begin
SlotClose;
QEvent_ignore(Event);
end;
With QWidgetLCL patch this works OK, without - not.
Thanks for QStringList addons ;)
zeljko
More information about the Qt
mailing list