ui/qt/button.cpp

changeset 520
ea1bba55de44
parent 516
4b31c74666d7
child 526
f6a6b0b08641
--- a/ui/qt/button.cpp	Wed Mar 26 21:47:04 2025 +0100
+++ b/ui/qt/button.cpp	Wed Mar 26 21:54:42 2025 +0100
@@ -30,3 +30,20 @@
 #include "container.h"
 #include "toolkit.h"
 
+UIWIDGET ui_button_create(UiObject* obj, UiButtonArgs args) {
+    UiContainerPrivate *ctn = ui_obj_container(obj);
+    UI_APPLY_LAYOUT(ctn->layout, args);
+    
+    QString str = QString::fromUtf8(args.label);
+    QPushButton *button = new QPushButton(str);
+    
+    if(args.onclick) {
+        UiEventWrapper *event = new UiEventWrapper(obj, args.onclick, args.onclickdata);
+        button->connect(button, SIGNAL(clicked()), event, SLOT(slot()));
+    }
+    
+    ctn->add(button, false);
+    
+    return button;
+}
+

mercurial