checkBox added

This commit is contained in:
Syping 2018-08-23 17:17:27 +02:00
parent 115d384f88
commit fb6a449d83
3 changed files with 31 additions and 0 deletions

View file

@ -29,6 +29,7 @@ local labelLayout
local appLabel1
local appLabel2
local pushButton1
local checkBox1
function main()
mainWindow = createMainWindow()
@ -50,6 +51,9 @@ function main()
appLabel2 = createLabel("..and not only one time!", mainWidget)
layoutAddWidget(labelLayout, appLabel2)
checkBox1 = createCheckBox("Want to check me?", mainWidget)
layoutAddWidget(mainLayout, checkBox1)
pushButton1 = createPushButton("Press me hard please!", mainWidget)
layoutAddWidget(mainLayout, pushButton1)
connect(pushButton1, "clicked()", "showHarderBox")

View file

@ -24,6 +24,7 @@
#include <QTextStream>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QMenuBar>
#include <QProcess>
#include <QObject>
@ -59,6 +60,9 @@ void LuaEngineGui::pushClass(lua_State *L_p)
pushVariant(L_p, "ShowMaximised", 3);
pushVariant(L_p, "ShowFullscreen", 4);
// Check Box
pushFunction(L_p, "createCheckBox", createCheckBox);
// Label
pushFunction(L_p, "createLabel", createLabel);
@ -228,6 +232,28 @@ int LuaEngineGui::createCentralWidget(lua_State *L_p)
return 0;
}
int LuaEngineGui::createCheckBox(lua_State *L_p)
{
QVariantList args = getArguments(L_p);
QWidget *parent = nullptr;
QString labelText = "LuaEngine";
if (args.length() >= 1) {
labelText = args.at(0).toString();
if (args.length() >= 2) {
if ((QMetaType::Type)args.at(1).type() == QMetaType::Void || (QMetaType::Type)args.at(1).type() == QMetaType::VoidStar) {
if (((QObject*)qvariant_cast<void*>(args.at(1)))->inherits("QWidget")) {
parent = (QWidget*)qvariant_cast<void*>(args.at(1));
}
}
}
}
QCheckBox *checkBox = new QCheckBox(parent);
checkBox->setObjectName(nameForPointer(checkBox));
checkBox->setText(labelText);
pushPointer(L_p, checkBox);
return 1;
}
int LuaEngineGui::createLabel(lua_State *L_p)
{
QVariantList args = getArguments(L_p);

View file

@ -36,6 +36,7 @@ public:
static int layoutAddLayout(lua_State *L_p);
static int layoutAddWidget(lua_State *L_p);
static int createCentralWidget(lua_State *L_p);
static int createCheckBox(lua_State *L_p);
static int createLabel(lua_State *L_p);
static int createLayout(lua_State *L_p);
static int createMainWindow(lua_State *L_p);