libqtlua-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libqtlua-list] Lua namespace does not fit in with Qt reference


From: Kern, Tobias
Subject: [Libqtlua-list] Lua namespace does not fit in with Qt reference
Date: Mon, 8 Sep 2014 13:10:55 +0000

Hello everybody,

 

I recently discovered some issues using libqtlua-2.0 with Qt 4.6.3. My goal was to call a QDialog in modal (!!!) mode from within an MFC application using Lua.

 

I was able to create a QDialog in Lua and also achieved calling it (using the Qt/MFC migration framework), but this dialog was not modal! I figured out, that it was necessary to set the modality directly in Lua; at first I thought, calling the QMfcApp::exec()-function would be enough, but I was wrong, obviously.

 

In the Qt reference, I found the property “setModal( bool modal )”, which is documented in Qt 4.6.3 as well as in all other Qt versions being tested for compatibility with libqtlua-2.0. So I assumed, calling this property would solve my problem. In fact, this didn’t solve my problems in any way but revealed other issues that I thought you really have to know about.

 

At first you might ask yourself: what happens if I call this “setModal”-property. Well, Lua just tells you that you are “[…] indexing ‘setModal’ (a nil value)”.

 

So what to do now? After getting an overview I happened to find the lines that were responsible for the creation of the meta-object-stuff. I figured out that in there, all the public slots, signals and properties of each Q-what-so-ever being used and referred to in Lua were created during runtime. All those functions are stored in a list called “_member_cache”; please correct me, if I am wrong here.

 

I assumed that in this cache, there also had to be a function “setModal” or anything similar; according to the Qt reference it really had to be. But it wasn’t. The only thing I could find were references to two properties called “modal” and “modal_p”. “modal” was in the cache for the OWidgets, “modal_p” was assigned to the QDialog-cache.

Which one is now the correct to use? I figured out that one pretty fast though, because “modal” was read only (as far as Lua tells you).

 

What I really don’t understand is:

1)      Why is there no “setModal”-property even though it is documented in the Qt references?

2)      Why do you rename the property “modal” to “modal_p”?

3)      Why do you even rename things and therefore leave the Qt specification? In the file “qtluametacache.cc”, there are three lines where you are doing that: for methods, enumerations and properties.

 

And as far as I could figure out, all these things above also come up when trying to use another property of QDialog called “setSizeGripEnabled”. This leads me to the assumption that the property-handling of QtLua in general has some bugs.

 

I’ve commented out those lines in “qtluametacache.cc” mentioned above and have called the modal-property like: “myQtDialog.modal = true” in Lua and: The dialog now displayed is modal!

 

I don’t know what you are going to do with this information. I hope it will contribute to an improvement of the QtLua-project as this is really a great tool to work with.

 

Best regards

 

 

P.S.: Modality of Qt-Widgets and MFC/win32-applications is a really tricky thing. A central element is the QWinWidget in the Qt/MFC migration framework. This widget MUST be the parent of all other QWidgets you create; even of those being created in the Lua script! I was not able to find any information about how to achieve this parenting-stuff using standard mechanisms. I, too, had to modify the code here and there, but this is another issue. I just wanted to add this for the sake of completeness.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]