Today I want to use LUA for data manipulation in QT
It turns out that there are fewer articles using LUA in Qt, though it's simple, but it's written to provide a primer, by the way, to record
I'm using the QT Creator 3.4.2, with the mingw4.9.2 compiler.
The LUA version I downloaded on the LUA website is 5.3.1
First, in the QT to compile Lua, get. A and DLL these two files
Create a new file or Project->library->c++ library in Qt creator-> file, and then follow the next steps to complete the creation
Then, right-click on your own project, choose Add Existing file, add the src file of downloaded good Lua file, except lua.c and luac.c These two files, the rest are imported , of course that makefile also do not
That's probably it.
Next choose Compile as release, then click Build
Well, the directory I compiled here is build-lua-desktop_qt_5_5_0_mingw_32bit-release.
In the release folder inside Find Liblua.a and Lua.dll, my side directly after the construction of these two
Finally, copy the two into the downloaded Lua folder and you can use the
How to use:
Import in your own Pro file first
Includepath += + E:\Lua\liblua.a
Then copy the DLL to the debug or Release directory in your project (e.g. Build-lua-desktop_qt_5_5_0_mingw_32bit-release)
To experiment with a CPP, here are just a few examples
1#include"kv_read_write.h"2#include"Qdebug"3 4 extern "C"5 {6#include"lua.h"7#include"Lauxlib.h"8#include"Lualib.h"9 }Ten One Keyvalue::keyvalue () A { -lua_state* L =lual_newstate (); -Lua_pushstring (L,"123"); theQdebug (Lua_tostring (L,1)); - Lua_close (L); -}
The above method is verified by me to be feasible.
I do not have a lot of experience in the use of Hucou, there are errors please point out
QT Learning notes: Using LUA in QT