mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2025-01-03 09:39:43 +01:00
make createCentralWidget not necessary
This commit is contained in:
parent
643b025a83
commit
ba59a81d68
3 changed files with 47 additions and 19 deletions
|
@ -22,8 +22,7 @@ local dialogLineEdit
|
||||||
|
|
||||||
function main()
|
function main()
|
||||||
mainWindow = createMainWindow()
|
mainWindow = createMainWindow()
|
||||||
local mainWidget = createCentralWidget(mainWindow)
|
local mainLayout = createLayout(VerticalLayout, mainWindow)
|
||||||
local mainLayout = createLayout(VerticalLayout, mainWidget)
|
|
||||||
|
|
||||||
local menuBar = createMenuBar(mainWindow)
|
local menuBar = createMenuBar(mainWindow)
|
||||||
local menuFile = createMenu("File", menuBar)
|
local menuFile = createMenu("File", menuBar)
|
||||||
|
@ -36,15 +35,15 @@ function main()
|
||||||
connect(menuEntryAbout, "triggered()", "showAboutBox")
|
connect(menuEntryAbout, "triggered()", "showAboutBox")
|
||||||
|
|
||||||
local labelLayout = createLayout(HorizontalLayout, mainLayout)
|
local labelLayout = createLayout(HorizontalLayout, mainLayout)
|
||||||
local appLabel1 = createLabel("LuaEngine greets!", mainWidget)
|
local appLabel1 = createLabel("LuaEngine greets!", mainWindow)
|
||||||
layoutAddWidget(labelLayout, appLabel1)
|
layoutAddWidget(labelLayout, appLabel1)
|
||||||
local appLabel2 = createLabel("..and not only one time!", mainWidget)
|
local appLabel2 = createLabel("..and not only one time!", mainWindow)
|
||||||
layoutAddWidget(labelLayout, appLabel2)
|
layoutAddWidget(labelLayout, appLabel2)
|
||||||
|
|
||||||
local checkBox1 = createCheckBox("Want to check me?", mainWidget)
|
local checkBox1 = createCheckBox("Want to check me?", mainWindow)
|
||||||
layoutAddWidget(mainLayout, checkBox1)
|
layoutAddWidget(mainLayout, checkBox1)
|
||||||
|
|
||||||
local pushButton1 = createPushButton("Press me hard please!", mainWidget)
|
local pushButton1 = createPushButton("Press me hard please!", mainWindow)
|
||||||
layoutAddWidget(mainLayout, pushButton1)
|
layoutAddWidget(mainLayout, pushButton1)
|
||||||
connect(pushButton1, "clicked()", "showDialog")
|
connect(pushButton1, "clicked()", "showDialog")
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,7 @@ local textEditor
|
||||||
|
|
||||||
function main()
|
function main()
|
||||||
mainWindow = createMainWindow("LE Text Editor")
|
mainWindow = createMainWindow("LE Text Editor")
|
||||||
local mainWidget = createCentralWidget(mainWindow)
|
local mainLayout = createLayout(VerticalLayout, mainWindow)
|
||||||
local mainLayout = createLayout(VerticalLayout, mainWidget)
|
|
||||||
setLayoutMargins(mainLayout, 0, 0, 0, 0)
|
setLayoutMargins(mainLayout, 0, 0, 0, 0)
|
||||||
|
|
||||||
local menuBar = createMenuBar(mainWindow)
|
local menuBar = createMenuBar(mainWindow)
|
||||||
|
@ -49,7 +48,7 @@ function main()
|
||||||
setMenuShortcut(menuEntryAbout, "Ctrl+P")
|
setMenuShortcut(menuEntryAbout, "Ctrl+P")
|
||||||
connect(menuEntryAbout, "triggered()", "editorAboutBox")
|
connect(menuEntryAbout, "triggered()", "editorAboutBox")
|
||||||
|
|
||||||
textEditor = createPlainTextEdit("", mainWidget)
|
textEditor = createPlainTextEdit("", mainWindow)
|
||||||
layoutAddWidget(mainLayout, textEditor)
|
layoutAddWidget(mainLayout, textEditor)
|
||||||
|
|
||||||
setWidgetSize(mainWindow, 650, 450)
|
setWidgetSize(mainWindow, 650, 450)
|
||||||
|
|
|
@ -513,7 +513,10 @@ int LuaEngineGui::createCheckBox(lua_State *L_p)
|
||||||
labelText = getVariant(L_p, 1).toString();
|
labelText = getVariant(L_p, 1).toString();
|
||||||
if (getArgumentCount(L_p) >= 2) {
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
void *pointer = getPointer(L_p, 2);
|
void *pointer = getPointer(L_p, 2);
|
||||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
|
||||||
|
parent = ((QMainWindow*)pointer)->centralWidget();
|
||||||
|
}
|
||||||
|
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||||
parent = (QWidget*)pointer;
|
parent = (QWidget*)pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,7 +561,10 @@ int LuaEngineGui::createLabel(lua_State *L_p)
|
||||||
labelText = getVariant(L_p, 1).toString();
|
labelText = getVariant(L_p, 1).toString();
|
||||||
if (getArgumentCount(L_p) >= 2) {
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
void *pointer = getPointer(L_p, 2);
|
void *pointer = getPointer(L_p, 2);
|
||||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
|
||||||
|
parent = ((QMainWindow*)pointer)->centralWidget();
|
||||||
|
}
|
||||||
|
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||||
parent = (QWidget*)pointer;
|
parent = (QWidget*)pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -576,7 +582,10 @@ int LuaEngineGui::createLayout(lua_State *L_p)
|
||||||
QLayout *layoutParent = nullptr;
|
QLayout *layoutParent = nullptr;
|
||||||
if (getArgumentCount(L_p) >= 2) {
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
void *pointer = getPointer(L_p, 2);
|
void *pointer = getPointer(L_p, 2);
|
||||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
|
||||||
|
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")) {
|
else if (pointer != NULL && ((QObject*)pointer)->inherits("QLayout")) {
|
||||||
|
@ -616,7 +625,10 @@ int LuaEngineGui::createLineEdit(lua_State *L_p)
|
||||||
editText = getVariant(L_p, 1).toString();
|
editText = getVariant(L_p, 1).toString();
|
||||||
if (getArgumentCount(L_p) >= 2) {
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
void *pointer = getPointer(L_p, 2);
|
void *pointer = getPointer(L_p, 2);
|
||||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
|
||||||
|
parent = ((QMainWindow*)pointer)->centralWidget();
|
||||||
|
}
|
||||||
|
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||||
parent = (QWidget*)pointer;
|
parent = (QWidget*)pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -632,18 +644,27 @@ int LuaEngineGui::createMainWindow(lua_State *L_p)
|
||||||
{
|
{
|
||||||
QWidget *parent = nullptr;
|
QWidget *parent = nullptr;
|
||||||
QString windowTitle = "LuaEngine";
|
QString windowTitle = "LuaEngine";
|
||||||
|
bool centralWidget = true;
|
||||||
if (getArgumentCount(L_p) >= 1) {
|
if (getArgumentCount(L_p) >= 1) {
|
||||||
windowTitle = getVariant(L_p, 1).toString();
|
windowTitle = getVariant(L_p, 1).toString();
|
||||||
if (getArgumentCount(L_p) >= 2) {
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
void *pointer = getPointer(L_p, 2);
|
centralWidget = getVariant(L_p, 2).toBool();
|
||||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
if (getArgumentCount(L_p) >= 3) {
|
||||||
parent = (QWidget*)pointer;
|
void *pointer = getPointer(L_p, 3);
|
||||||
|
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||||
|
parent = (QWidget*)pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QMainWindow *mainWindow = new QMainWindow(parent);
|
QMainWindow *mainWindow = new QMainWindow(parent);
|
||||||
mainWindow->setObjectName(nameForPointer(mainWindow));
|
mainWindow->setObjectName(nameForPointer(mainWindow));
|
||||||
mainWindow->setWindowTitle(windowTitle);
|
mainWindow->setWindowTitle(windowTitle);
|
||||||
|
if (centralWidget) {
|
||||||
|
QWidget *centralWidget = new QWidget(mainWindow);
|
||||||
|
centralWidget->setObjectName(nameForPointer(centralWidget));
|
||||||
|
mainWindow->setCentralWidget(centralWidget);
|
||||||
|
}
|
||||||
pushPointer(L_p, mainWindow);
|
pushPointer(L_p, mainWindow);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -723,7 +744,10 @@ int LuaEngineGui::createPlainTextEdit(lua_State *L_p)
|
||||||
editText = getVariant(L_p, 1).toString();
|
editText = getVariant(L_p, 1).toString();
|
||||||
if (getArgumentCount(L_p) >= 2) {
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
void *pointer = getPointer(L_p, 2);
|
void *pointer = getPointer(L_p, 2);
|
||||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
|
||||||
|
parent = ((QMainWindow*)pointer)->centralWidget();
|
||||||
|
}
|
||||||
|
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||||
parent = (QWidget*)pointer;
|
parent = (QWidget*)pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -743,7 +767,10 @@ int LuaEngineGui::createPushButton(lua_State *L_p)
|
||||||
buttonText = getVariant(L_p, 1).toString();
|
buttonText = getVariant(L_p, 1).toString();
|
||||||
if (getArgumentCount(L_p) >= 2) {
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
void *pointer = getPointer(L_p, 2);
|
void *pointer = getPointer(L_p, 2);
|
||||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
|
||||||
|
parent = ((QMainWindow*)pointer)->centralWidget();
|
||||||
|
}
|
||||||
|
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||||
parent = (QWidget*)pointer;
|
parent = (QWidget*)pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -787,7 +814,10 @@ int LuaEngineGui::createTextEdit(lua_State *L_p)
|
||||||
editText = getVariant(L_p, 1).toString();
|
editText = getVariant(L_p, 1).toString();
|
||||||
if (getArgumentCount(L_p) >= 2) {
|
if (getArgumentCount(L_p) >= 2) {
|
||||||
void *pointer = getPointer(L_p, 2);
|
void *pointer = getPointer(L_p, 2);
|
||||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
|
||||||
|
parent = ((QMainWindow*)pointer)->centralWidget();
|
||||||
|
}
|
||||||
|
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||||
parent = (QWidget*)pointer;
|
parent = (QWidget*)pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue