Sign in Join

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

Mailing lists / qt / 2007-07

FPC Qt4 Binding V1.39

13 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Den Jean

Hi,

Please test FPC Qt4 Binding V1.39:
http://users.pandora.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html

1) QstringList = QList<QString>
====================
I added the methods inherited from QList.
See demo Mainwindow (QFontdatabase_families)

You cannot instantiate just QList, as the template T needs to be defined. so you will not find QList_size or so, that is not possible -> QStringList_size.

For other QList<T>, I can now also do this. It only a bit of work.

2) QRect:
======
Fixed for Darwin. QPoint is not fixed yet. Please test QRect first. and also test that Point is incorrect for now on Darwin. How did any program work before on Darwin ???

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

regards,

Den Jean

Reply by email

Felipe Monteiro de Carvalho
to Den Jean
Den Jean wrote 5 lines
2) QRect: ====== Fixed for Darwin. QPoint is not fixed yet. Please test QRect first. and also test that Point is incorrect for now on Darwin. How did any program work before on Darwin ???

I compiled the files you sent me on my Mac and nothing seams fixed about the rects =/

Althougth I still need to test more.

thanks,

Felipe Monteiro de Carvalho

Reply by email

zeljko
to Den Jean: Please test FPC Qt4 Binding V1.39: http://users.pandora.be/Jan.Van.hijfte/qtforfpc/fpcqt4.…
Den Jean wrote 12 lines
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

Reply by email

Den Jean
to zeljko: No, Den it cannot work since we don't have anything like that in our qt-lcl code. There's…
am zeljko wrote
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().

It also expected that you read/need the result from delivermessage, but a test revealed that the result is not different with CanClose True or False in a FormCloseQuery.

The design of SlotClose is up to you/Felipe.
Probably with the "cdecl" Felipe wanted one day to connect stuff to these Qt compatible slots. But you can change it to a function and add parameters if you want.

Here's a patch that implements CloseQuery:

Tested by creating an App with a Form with a CheckBox ECanClose.
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin
  CanClose:=ECanClose.Checked;
end;

The delivermessage and the convenience functions (LCLSendCloseQueryMsg) of LCLMessageGlue are really nice. I would really like that you overall use these functions. It would reduce the size of QtWidgets.pas.

kind regards,

Den Jean

-------------- next part --------------
A non-text attachment was scrubbed...
Name: r11412_CloseQuery.diff
Type: text/x-diff
Size: 1172 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/qt/attachments/20070704/8ea64bbc/attachment.bin>

Reply by email

Unknown author
to Den Jean

Quoting Den Jean :

Show quoted text 16 lines
On Wednesday 04 July 2007 09:44:27 am zeljko wrote: > 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(). It also expected that you read/need the result from delivermessage, but a test revealed that the result is not different with CanClose True or False in a FormCloseQuery. The design of SlotClose is up to you/Felipe. Probably with the "cdecl" Felipe wanted one day to connect stuff to these Qt compatible slots. But you can change it to a function and add parameters if you want. Here's a patch that implements CloseQuery:

sorry Den but this patch doesn't fix the problem,I've just tried it. QWidget::closeEvent() is accepted by default, whatever you do in form OnCloseQuery() event,
--->>>>> but just when you close form via titlebar "X" button <---- , not when you close it via LCL call, like buttonPress()->Close(). That's the point, Qt manages this click not LCL since LCL have nothing with minimize,maximize,close (titlebar) etc. buttons. So when you click it , it's already accepted, all additional changes on this event are lost (eg. ignore).
Beleive me, I've spent few days in testing all solutions around this problem, and only closeEvent() overriding fixes things.

Show quoted text 10 lines
Tested by creating an App with a Form with a CheckBox ECanClose. procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean); begin CanClose:=ECanClose.Checked; end; The delivermessage and the convenience functions (LCLSendCloseQueryMsg) of LCLMessageGlue are really nice. I would really like that you overall use these functions. It would reduce the size of QtWidgets.pas.

It's not problem to use messages, but some things have to be handled and interacted directly with qt.

zeljko

Reply by email

Den Jean
to Unknown author
pm wrote 11 lines
sorry Den but this patch doesn't fix the problem,I've just tried it. QWidget::closeEvent() is accepted by default, whatever you do in form ? OnCloseQuery() event, --->>>>> but just when you close form via titlebar "X" button <---- , not when you close it via LCL call, like buttonPress()->Close(). ? That's the point, Qt manages this click not LCL since LCL have nothing ? with minimize,maximize,close (titlebar) etc. buttons. So when you click it , it's already accepted, all additional changes ? on this event are lost (eg. ignore). Beleive me, I've spent few days in testing all solutions around this ? problem, and only closeEvent() overriding fixes things.

Strange, I tested both "X" button and Form.Close. Both work as expected: when CanClose false -> app does not close.
Please try again.

I will send LCL/Qt binary as proof in private.
Test:
* Leave CanClose ChexBox unchecked: click X or Button2 (with Close statement) -> app does not close
* Check CanClose CheckBox: click X or Button2 -> app closes

regards,

Den Jean

Reply by email

Unknown author
to Den Jean

Quoting Den Jean :

Show quoted text 16 lines
On Wednesday 04 July 2007 08:24:35 pm wrote: > sorry Den but this patch doesn't fix the problem,I've just tried it. > QWidget::closeEvent() is accepted by default, whatever you do in > form OnCloseQuery() event, > --->>>>> but just when you close form via titlebar "X" button <---- , > not when you close it via LCL call, like buttonPress()->Close(). > That's the point, Qt manages this click not LCL since LCL have > nothing with minimize,maximize,close (titlebar) etc. buttons. > So when you click it , it's already accepted, all additional > changes on this event are lost (eg. ignore). > Beleive me, I've spent few days in testing all solutions around > this problem, and only closeEvent() overriding fixes things. Strange, I tested both "X" button and Form.Close. Both work as expected: when CanClose false -> app does not close. Please try again.

hum...now I'm really mad. Your binary works ok, recompiled on my machine - not.
My configuration (at home-currently):
1.Qt-4.3.0 - compiled with --no-stl
2.XOrg 6.8.2
3.Kernel-2.6.16
4.Glibc 2.3.4

My configuration (at work - my devel machine):
1.Qt-4.3.0 - compiled with --no-stl
2.XOrg 6.8.2
3.Kernel-2.6.20
4.Glibc-2.3.4

and I've compiled bindings on my own. I'll check this scenario once again tomorrow on WinXp machine (there are original bindings + mingw compiled qt)
Thanks for providing demo :)

Any ?

Reply by email

Den Jean
to Unknown author: Quoting Den Jean : hum...now I'm really mad. Your binary works ok, recompiled on my…
pm wrote
hum...now I'm really mad. Your binary works ok, recompiled on my ? machine - not.

relief on my side -:) (I guess you checked with ldd ./project1 :-;)

My configuration:
1.Qt-4.3.0 : configure -prefix /usr -opengl -randier -xcursor -xrandr 2.XOrg 7.2.0
3.Kernel-2.6.17
4.glibc-2.4-8mdv2007.1

#gcc -v
Using built-in specs.
Target: i586-mandriva-linux-gnu
Configured
with: ../configure --prefix=/usr --libexecdir=/usr/lib --with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-checking=release --enable-languages=c,c++,ada,fortran,objc,obj-c++,java --host=i586-mandriva-linux-gnu --with-cpu=generic --with-system-zlib --enable-threads=posix --enable-shared --enable-long-long --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --enable-gtk-cairo --disable-libjava-multilib --enable-ssp --disable-libssp Thread model: posix
gcc version 4.1.2 20070302 (prerelease) (4.1.2-1mdv2007.1)

regards,

Den Jean

Reply by email

Den Jean
to Felipe Monteiro de Carvalho: On 7/4/07, Felipe Monteiro de Carvalho My mistake! I had to remove the old framework…
am Felipe Monteiro de Carvalho wrote
Please fix TPoint in the same way

Done: FPC Qt4 Binding V1.40:
http://users.pandora.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html

please test on Linux/Darwin before I do effort of making windows binary.

You will need to patch lcl/qt

Index: lcl/interfaces/qt/qt4.pas
=================================================================== --- lcl/interfaces/qt/qt4.pas (revision 11421)
+++ lcl/interfaces/qt/qt4.pas (working copy)
@@ -1046,7 +1050,7 @@

   FillChar(Msg, SizeOf(Msg), #0);
-  MousePos := QMouseEvent_pos(QMouseEventH(Event))^;
+  QMouseEvent_pos(QMouseEventH(Event), at MousePos);
   Msg.Keys := 0;
   Modifiers := QInputEvent_modifiers(QInputEventH(Event));
@@ -1131,7 +1135,7 @@
 begin
   FillChar(Msg, SizeOf(Msg), #0);
-  MousePos := QMouseEvent_pos(QMouseEventH(Event))^;
+  QMouseEvent_pos(QMouseEventH(Event), at MousePos);
   //QCursor_pos(@MousePos);
@@ -1160,7 +1164,7 @@
 begin
   FillChar(Msg, SizeOf(Msg), #0);
-  MousePos := QWheelEvent_pos(QWheelEventH(Event))^;
+  QWheelEvent_pos(QWheelEventH(Event), at MousePos);
   Msg.Msg := LM_MOUSEWHEEL;

Reply by email

Unknown author
to Den Jean: relief on my side -:) (I guess you checked with ldd ./project1 :-;) My configuration:…

Quoting Den Jean :

On Wednesday 04 July 2007 09:56:54 pm wrote: > hum...now I'm really mad. Your binary works ok, recompiled on my > machine - not. relief on my side -:) (I guess you checked with ldd ./project1 :-;)

seem that my qt binaries doesn't do same job as yours (my gcc is 3.4.2), so I'll install fc7 next days (maybe tommorrow), and test there, but the problem is that I cannot reinstall my devel machine (FC3 with bunch of upgrades), since there is still Kylix3 sitting and doing some job ;)
Anyway it's good to know that we can expect bug reports from users if they use older distros.

Reply by email