fix lpForPointer function

This commit is contained in:
Syping 2020-05-16 17:23:58 +02:00
parent 807bcdd597
commit 1823511204
2 changed files with 17 additions and 17 deletions

View File

@ -720,7 +720,7 @@ int LuaEngineGui::createCheckBox(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
labelText = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
}
}
QCheckBox *checkBox = new QCheckBox(parent);
@ -766,7 +766,7 @@ int LuaEngineGui::createGroupBox(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
groupBoxTitle = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
}
}
QGroupBox *groupBox = new QGroupBox(parent);
@ -787,7 +787,7 @@ int LuaEngineGui::createLabel(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
labelText = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
}
}
QLabel *label = new QLabel(parent);
@ -849,7 +849,7 @@ int LuaEngineGui::createLineEdit(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
editText = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
}
}
QLineEdit *lineEdit = new QLineEdit(parent);
@ -970,7 +970,7 @@ int LuaEngineGui::createPlainTextEdit(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
editText = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
}
}
QPlainTextEdit *textEdit = new QPlainTextEdit(parent);
@ -993,7 +993,7 @@ int LuaEngineGui::createProgressBar(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
value = getVariant(L_p, 1).toInt();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
if (getArgumentCount(L_p) >= 4) {
minValue = getVariant(L_p, 3).toInt();
maxValue = getVariant(L_p, 4).toInt();
@ -1020,7 +1020,7 @@ int LuaEngineGui::createPushButton(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
buttonText = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
}
}
QPushButton *pushButton = new QPushButton(parent);
@ -1041,7 +1041,7 @@ int LuaEngineGui::createRadioButton(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
labelText = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
}
}
QRadioButton *radioButton = new QRadioButton(parent);
@ -1083,7 +1083,7 @@ int LuaEngineGui::createTabBar(lua_State *L_p)
QLayout *layout = nullptr;
QWidget *parent = nullptr;
if (getArgumentCount(L_p) >= 1) {
lpForPointer(getPointer(L_p, 1), layout, parent);
lpForPointer(getPointer(L_p, 1), &layout, &parent);
}
QTabWidget *tabWidget = new QTabWidget(parent);
tabWidget->setObjectName(nameForPointer(tabWidget));
@ -1102,7 +1102,7 @@ int LuaEngineGui::createTextEdit(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
editText = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
}
}
QTextEdit *textEdit = new QTextEdit(parent);
@ -1123,7 +1123,7 @@ int LuaEngineGui::createToolButton(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
buttonText = getVariant(L_p, 1).toString();
if (getArgumentCount(L_p) >= 2) {
lpForPointer(getPointer(L_p, 2), layout, parent);
lpForPointer(getPointer(L_p, 2), &layout, &parent);
}
}
QToolButton *toolButton = new QToolButton(parent);
@ -1263,19 +1263,19 @@ QWidget* LuaEngineGui::windowForObject(QObject *object)
return nullptr;
}
void LuaEngineGui::lpForPointer(void *pointer, QLayout *layout, QWidget *parent)
void LuaEngineGui::lpForPointer(void *pointer, QLayout **layout, QWidget **parent)
{
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
parent = ((QMainWindow*)pointer)->centralWidget();
*parent = ((QMainWindow*)pointer)->centralWidget();
}
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
parent = (QWidget*)pointer;
*parent = (QWidget*)pointer;
}
else if (pointer != NULL && ((QObject*)pointer)->inherits("QLayout")) {
QWidget *widget = windowForObject((QObject*)pointer);
if (widget != nullptr) {
layout = (QLayout*)pointer;
parent = widget;
*layout = (QLayout*)pointer;
*parent = widget;
}
}
}

View File

@ -82,7 +82,7 @@ public:
private:
lua_State *L;
static QWidget* windowForObject(QObject *object);
static void lpForPointer(void *pointer, QLayout *layout, QWidget *parent);
static void lpForPointer(void *pointer, QLayout **layout, QWidget **parent);
static QString nameForPointer(void *pointer);
};