mirror of
				https://gitlab.com/Syping/luaengineapp.git
				synced 2025-10-31 02:20:20 +01:00 
			
		
		
		
	improvements
This commit is contained in:
		
							parent
							
								
									ec4fb13212
								
							
						
					
					
						commit
						b8a5843464
					
				
					 7 changed files with 96 additions and 1 deletions
				
			
		|  | @ -27,6 +27,7 @@ | |||
| #include <QVBoxLayout> | ||||
| #include <QSizePolicy> | ||||
| #include <QEventLoop> | ||||
| #include <QTextEdit> | ||||
| #include <QLineEdit> | ||||
| #include <QCheckBox> | ||||
| #include <QMenuBar> | ||||
|  | @ -36,6 +37,7 @@ | |||
| #include <QDialog> | ||||
| #include <QTimer> | ||||
| #include <QLabel> | ||||
| #include <QDebug> | ||||
| 
 | ||||
| LuaEngineGui::LuaEngineGui(QObject *parent, bool loadBaseLibraries) : LuaEngine(parent, loadBaseLibraries) | ||||
| { | ||||
|  | @ -103,6 +105,9 @@ void LuaEngineGui::pushClass(lua_State *L_p) | |||
|     // Spacer Item
 | ||||
|     pushFunction(L_p, "createSpacerItem", createSpacerItem); | ||||
| 
 | ||||
|     // Line Edit
 | ||||
|     pushFunction(L_p, "createTextEdit", createTextEdit); | ||||
| 
 | ||||
|     // Size Policy
 | ||||
|     pushVariant(L_p, "SizePolicyFixed", (int)QSizePolicy::Fixed); | ||||
|     pushVariant(L_p, "SizePolicyMinimum", (int)QSizePolicy::Minimum); | ||||
|  | @ -302,6 +307,9 @@ int LuaEngineGui::setWidgetText(lua_State *L_p) | |||
|             else if (((QObject*)pointer)->inherits("QLineEdit")) { | ||||
|                 ((QLineEdit*)pointer)->setText(getVariant(L_p, 2).toString()); | ||||
|             } | ||||
|             else if (((QObject*)pointer)->inherits("QTextEdit")) { | ||||
|                 ((QTextEdit*)pointer)->setText(getVariant(L_p, 2).toString()); | ||||
|             } | ||||
|             else if (((QObject*)pointer)->inherits("QWidget")) { | ||||
|                 ((QWidget*)pointer)->setWindowTitle(getVariant(L_p, 2).toString()); | ||||
|             } | ||||
|  | @ -609,6 +617,28 @@ int LuaEngineGui::createSpacerItem(lua_State *L_p) | |||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| int LuaEngineGui::createTextEdit(lua_State *L_p) | ||||
| { | ||||
|     QVariantList args = getArguments(L_p); | ||||
|     QWidget *parent = nullptr; | ||||
|     QString editText = "LuaEngine"; | ||||
|     if (args.length() >= 1) { | ||||
|         editText = 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)); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     QTextEdit *textEdit = new QTextEdit(parent); | ||||
|     textEdit->setObjectName(nameForPointer(textEdit)); | ||||
|     textEdit->setText(editText); | ||||
|     pushPointer(L_p, textEdit); | ||||
|     return 1; | ||||
| } | ||||
| 
 | ||||
| int LuaEngineGui::getParent(lua_State *L_p) | ||||
| { | ||||
|     if (getArgumentCount(L_p) >= 1) { | ||||
|  | @ -638,6 +668,10 @@ int LuaEngineGui::getWidgetText(lua_State *L_p) | |||
|                 pushVariant(L_p, ((QLineEdit*)pointer)->text()); | ||||
|                 return 1; | ||||
|             } | ||||
|             else if (((QObject*)pointer)->inherits("QTextEdit")) { | ||||
|                 pushVariant(L_p, ((QTextEdit*)pointer)->toPlainText()); | ||||
|                 return 1; | ||||
|             } | ||||
|             else if (((QObject*)pointer)->inherits("QWidget")) { | ||||
|                 pushVariant(L_p, ((QWidget*)pointer)->windowTitle()); | ||||
|                 return 1; | ||||
|  |  | |||
|  | @ -36,6 +36,7 @@ public: | |||
|     static int showWidget(lua_State *L_p); | ||||
|     static int setWidgetFixedSize(lua_State *L_p); | ||||
|     static int setWidgetLayout(lua_State *L_p); | ||||
|     static int setWidgetMargins(lua_State *L_p); | ||||
|     static int setWidgetText(lua_State *L_p); | ||||
|     static int layoutAddLayout(lua_State *L_p); | ||||
|     static int layoutAddWidget(lua_State *L_p); | ||||
|  | @ -51,6 +52,7 @@ public: | |||
|     static int createMenuEntry(lua_State *L_p); | ||||
|     static int createPushButton(lua_State *L_p); | ||||
|     static int createSpacerItem(lua_State *L_p); | ||||
|     static int createTextEdit(lua_State *L_p); | ||||
|     static int getParent(lua_State *L_p); | ||||
|     static int getWidgetText(lua_State *L_p); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue