bugQtLua script engine for Qt - Bugs: bug #36675, Lua SLOTs "self" element.


bug #36675: Lua SLOTs "self" element.

Submitted by:  Sergey <z80>
Submitted on:  Mon 18 Jun 2012 10:09:23 AM UTC  
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sat 14 Jul 2012 06:10:14 PM UTC, comment #1: 

Sorry for the late reply,

That's a nice feature, but it would be better to keep the 3 parameters version work as before and add the self value as an optional 4th parameter.

Please attach a diff patch next time rather then a zip archive containing the whole source tree. The mailing list is a nice place to discuss new features too :).

Alexandre Becoulet <diaxen>
Project Administrator
Mon 18 Jun 2012 10:09:23 AM UTC, original submission:  


I'm sorry for disturbing you so often! Using QtLua I've met the following issue. It would be convenient to use qt.connect() function when using Lua function as a SLOT with explicitly set "self" element.

In other words text such as:

ui = qt.load_ui( "form.ui" )
t = { stri = "Hi!" }
function t:func()
    print( tostring( self.stri ) )
qt.connect( ui.button01, "clicked", t, t.func )

at the moment is impossible, because sender() object is put as it's self element around line 150 in "qtluaqobjectwrapper.cc" and hardcoded. And one is to analyze it to understand what data should be used with particular slot call if one and the same Lua function is used. And one should care about keeping the data which should be used during slot call somewhere... may be in global variable...

I've extended QtLua::QObjectWrapper::LuaSlot with "_self" field, changed it's constructor and a bit modified "qt.connect()" and "_lua_connect()" function's code in order to get the result.

After modifications all "qt.connect()" implementations accept 4 arguments. First 2 are as before. In the case of Lua SLOT 3-rd one is "self" variable which will be substituted instead io hard coded "sender()". And the 4-th one is Lua function itself.

In order to get original functionality one should just make 3-rd and 1-st arguments the same.

I've attached the code with modifications. I hope it makes sense.

Sergey <z80>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by diaxen (Posted a comment)
  • -email is unavailable- added by z80 (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-07-14 diaxen Attached File#26052 => Removed
    2012-06-18 z80 Attached File- => Added qtlua-src-folder.zip, #26052

    Back to the top

    Powered by Savane 3.7