QT Learning notes: Using LUA in QT

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.