Added the original style of implementing custom Lua slots.
[lqt/mk.git] / README.md
bloba437ee92fb4d99d85a364daeb0c4bb13557e93ce
1 Overview
2 ========
4 lqt is a [Lua](http://www.lua.org) binding to the [Qt framework](http://qt.nokia.com).
5 It is an automated binding generated from the Qt headers, and covers almost
6 all classes and methods from supported Qt modules.
8 For more info, check the documentation, [mailing list](http://groups.google.com/group/lqt-bindings) or contact the authors:
10  * Michal Kottman michal.kottman@gmail.com
11  * Mauro Iazzi mauro.iazzi@gmail.com
12  * Peter Kümmel syntheticpp@gmx.net
14 Features
15 --------
17 * automatically generated from Qt headers - remains up-to-date even with as Qt progresses
18 * supported modules: QtCore, QtGui, QtNetwork, QtXml, QtXmlPatterns, QtWebKit, QtOpenGL, QtSql, QtSvg, QtUiTools
19 * high API coverage - only a minimum of methods are not available
20 * C++/Qt features available:
21   * method overloads
22   * virtual methods (including abstract methods)
23   * multiple inheritance
24   * you can store additional Lua values in userdata - they act like Lua tables
25   * several overloaded operators are supported
26   * chosen templated classes are available, like `QList<QString>`
27   * signal/slot mechanism - you can define custom slots in Lua
28   * `QObject` derived objects are automatically cast to correct type thanks to Qt metaobject system
29   * implicit conversion - i.e. write Lua strings where QString is expected, or numbers instead of QVariant
30 * optional memory management - you can let the Lua GC destroy objects, or let Qt parent/child management do the work
32 Building lqt
33 ------------
35 Pre-compiled Windows binaries of lqt compiled against Qt 4.7 compatible
36 with Lua for Windows [are available](https://github.com/downloads/mkottman/lqt/lqt_4.7_lfw_binaries.zip),
37 on other systems you need:
39 * Lua 5.1
40 * [CMake](http://www.cmake.org/cmake/resources/software.html)
41 * Qt and headers, on Ubuntu you need to install the `libqt4-dev` package
43 You can get the latest source of lqt from https://github.com/mkottman/lqt .
44 When you have the sources, create an out-of-source build directory
45 (where the binaries will be built, I often use `build` or `/dev/shm`).
46 Then, use CMake to generate the Makefile and run `make` as usual:
48     mkdir build; cd build
49     cmake ..
50     make -j4 # use parallel build with your number of cores/processors
52 The generated Lua binding libraries are created in the `lib` directory,
53 you can copy them to your `LUA_CPATH`.
55 Usage
56 -----
58 A quick example of "Hello World!" button with signal/slot handling:
60     require 'qtcore'
61     require 'qtgui'
63     app = QApplication.new(select('#',...) + 1, {'lua', ...})
65     btn = QPushButton.new("Hello World!")
66     btn:__addmethod('quitApp()', function(self)
67         print("I'm about to close...")
68         self:close()
69     end)
70     btn:connect('2pressed()', btn, '1quitApp()')
71     btn:setWindowTitle("A great example!")
72     btn:resize(300,50)
73     btn:show()
75     app.exec()
77 For more examples, check out the `test` folder and also the `doc`
78 folder for documentation on detailed usage - memory management,
79 signal/slot handling, virtual method overloading, etc.
81 License
82 -------
84 Copyright (c) 2007-2009 Mauro Iazzi
85 Copyright (c) 2008-2009 Peter Kümmel
86 Copyright (c) 2010-2011 Michal Kottman
88 Permission is hereby granted, free of charge, to any person
89 obtaining a copy of this software and associated documentation
90 files (the "Software"), to deal in the Software without
91 restriction, including without limitation the rights to use,
92 copy, modify, merge, publish, distribute, sublicense, and/or sell
93 copies of the Software, and to permit persons to whom the
94 Software is furnished to do so, subject to the following
95 conditions:
97 The above copyright notice and this permission notice shall be
98 included in all copies or substantial portions of the Software.
100 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
101 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
102 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
103 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
104 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
105 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
106 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
107 OTHER DEALINGS IN THE SOFTWARE.