groupBox added

This commit is contained in:
Syping 2020-05-15 12:23:42 +02:00
parent bf3d74fb21
commit 3a6780a82f
2 changed files with 46 additions and 0 deletions

View file

@ -35,6 +35,7 @@
#include <QEventLoop> #include <QEventLoop>
#include <QTextEdit> #include <QTextEdit>
#include <QLineEdit> #include <QLineEdit>
#include <QGroupBox>
#include <QCheckBox> #include <QCheckBox>
#include <QMenuBar> #include <QMenuBar>
#include <QProcess> #include <QProcess>
@ -106,6 +107,9 @@ void LuaEngineGui::pushClass(lua_State *L_p)
// Dialog // Dialog
pushFunction(L_p, "createDialog", createDialog); pushFunction(L_p, "createDialog", createDialog);
// Group Box
pushFunction(L_p, "createGroupBox", createGroupBox);
// Label // Label
pushFunction(L_p, "createLabel", createLabel); pushFunction(L_p, "createLabel", createLabel);
@ -570,6 +574,9 @@ int LuaEngineGui::setWidgetText(lua_State *L_p)
if (((QObject*)pointer)->inherits("QCheckBox")) { if (((QObject*)pointer)->inherits("QCheckBox")) {
((QCheckBox*)pointer)->setText(getVariant(L_p, 2).toString()); ((QCheckBox*)pointer)->setText(getVariant(L_p, 2).toString());
} }
else if (((QObject*)pointer)->inherits("QGroupBox")) {
((QGroupBox*)pointer)->setTitle(getVariant(L_p, 2).toString());
}
else if (((QObject*)pointer)->inherits("QLabel")) { else if (((QObject*)pointer)->inherits("QLabel")) {
((QLabel*)pointer)->setText(getVariant(L_p, 2).toString()); ((QLabel*)pointer)->setText(getVariant(L_p, 2).toString());
} }
@ -746,6 +753,40 @@ int LuaEngineGui::createDialog(lua_State *L_p)
return 1; return 1;
} }
int LuaEngineGui::createGroupBox(lua_State *L_p)
{
QLayout *layout = nullptr;
QWidget *parent = nullptr;
QString groupBoxTitle = "LuaEngine";
if (getArgumentCount(L_p) >= 1) {
groupBoxTitle = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
void *pointer = getPointer(L_p, 2);
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
parent = ((QMainWindow*)pointer)->centralWidget();
}
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
parent = (QWidget*)pointer;
}
else if (pointer != NULL && ((QObject*)pointer)->inherits("QLayout")) {
QWidget *widget = windowForObject((QObject*)pointer);
if (widget != nullptr) {
layout = (QLayout*)pointer;
parent = widget;
}
}
}
}
QGroupBox *groupBox = new QGroupBox(parent);
groupBox->setObjectName(nameForPointer(groupBox));
groupBox->setTitle(groupBoxTitle);
if (layout != nullptr) {
layout->addWidget(groupBox);
}
pushPointer(L_p, groupBox);
return 1;
}
int LuaEngineGui::createLabel(lua_State *L_p) int LuaEngineGui::createLabel(lua_State *L_p)
{ {
QLayout *layout = nullptr; QLayout *layout = nullptr;
@ -1248,6 +1289,10 @@ int LuaEngineGui::getWidgetText(lua_State *L_p)
pushVariant(L_p, ((QCheckBox*)pointer)->text()); pushVariant(L_p, ((QCheckBox*)pointer)->text());
return 1; return 1;
} }
if (((QObject*)pointer)->inherits("QGroupBox")) {
pushVariant(L_p, ((QGroupBox*)pointer)->title());
return 1;
}
else if (((QObject*)pointer)->inherits("QLabel")) { else if (((QObject*)pointer)->inherits("QLabel")) {
pushVariant(L_p, ((QLabel*)pointer)->text()); pushVariant(L_p, ((QLabel*)pointer)->text());
return 1; return 1;

View file

@ -55,6 +55,7 @@ public:
static int createCentralWidget(lua_State *L_p); static int createCentralWidget(lua_State *L_p);
static int createCheckBox(lua_State *L_p); static int createCheckBox(lua_State *L_p);
static int createDialog(lua_State *L_p); static int createDialog(lua_State *L_p);
static int createGroupBox(lua_State *L_p);
static int createLabel(lua_State *L_p); static int createLabel(lua_State *L_p);
static int createLayout(lua_State *L_p); static int createLayout(lua_State *L_p);
static int createLineEdit(lua_State *L_p); static int createLineEdit(lua_State *L_p);