mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
groupBox added
This commit is contained in:
parent
bf3d74fb21
commit
3a6780a82f
2 changed files with 46 additions and 0 deletions
|
@ -35,6 +35,7 @@
|
|||
#include <QEventLoop>
|
||||
#include <QTextEdit>
|
||||
#include <QLineEdit>
|
||||
#include <QGroupBox>
|
||||
#include <QCheckBox>
|
||||
#include <QMenuBar>
|
||||
#include <QProcess>
|
||||
|
@ -106,6 +107,9 @@ void LuaEngineGui::pushClass(lua_State *L_p)
|
|||
// Dialog
|
||||
pushFunction(L_p, "createDialog", createDialog);
|
||||
|
||||
// Group Box
|
||||
pushFunction(L_p, "createGroupBox", createGroupBox);
|
||||
|
||||
// Label
|
||||
pushFunction(L_p, "createLabel", createLabel);
|
||||
|
||||
|
@ -570,6 +574,9 @@ int LuaEngineGui::setWidgetText(lua_State *L_p)
|
|||
if (((QObject*)pointer)->inherits("QCheckBox")) {
|
||||
((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")) {
|
||||
((QLabel*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
|
@ -746,6 +753,40 @@ int LuaEngineGui::createDialog(lua_State *L_p)
|
|||
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)
|
||||
{
|
||||
QLayout *layout = nullptr;
|
||||
|
@ -1248,6 +1289,10 @@ int LuaEngineGui::getWidgetText(lua_State *L_p)
|
|||
pushVariant(L_p, ((QCheckBox*)pointer)->text());
|
||||
return 1;
|
||||
}
|
||||
if (((QObject*)pointer)->inherits("QGroupBox")) {
|
||||
pushVariant(L_p, ((QGroupBox*)pointer)->title());
|
||||
return 1;
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QLabel")) {
|
||||
pushVariant(L_p, ((QLabel*)pointer)->text());
|
||||
return 1;
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
static int createCentralWidget(lua_State *L_p);
|
||||
static int createCheckBox(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 createLayout(lua_State *L_p);
|
||||
static int createLineEdit(lua_State *L_p);
|
||||
|
|
Loading…
Reference in a new issue