From a9e0716c06f01e81d8b9c4ffb593e2ec34093f6b Mon Sep 17 00:00:00 2001 From: Aldo Nicolas Bruno Date: Fri, 23 Feb 2024 23:15:16 +0100 Subject: [PATCH] updated QskModelObjectBinder example --- playground/models/Window.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/playground/models/Window.cpp b/playground/models/Window.cpp index ac9e25d5..fdb9bc68 100644 --- a/playground/models/Window.cpp +++ b/playground/models/Window.cpp @@ -49,6 +49,7 @@ Window::Window( ) mapper->bindObject(spin, 0); // needs USER=true for value in QskBoundedInput mapper->bindObject(txt, 1); // needs USER=true for text in QskTextInput + // this loads the record from the first row and updates the controls data. mapper->selectRow(0); auto v = new QskLinearBox(Qt::Vertical); @@ -63,12 +64,19 @@ Window::Window( ) connect(next,&QskPushButton::clicked,[=]() { mapper->selectRow( 1 ); }); v->addItem(h); - auto save = new QskPushButton("Save",v); + auto save = new QskPushButton("Save Data to Model",v); connect(save,&QskPushButton::clicked,[=]() { + // this will update the current record with the data from the SpinBox and TextInput mapper->updateModel(); + // just for illustration we print out the record auto r = table->record(mapper->currentRow()); qDebug() << r; }); + auto set0 = new QskPushButton("Set Model field to 0",v); + connect(set0,&QskPushButton::clicked,[=]() { + // this should trigger the binder and update the spinbox + table->setData( table->index(mapper->currentRow(),0),0 ); + }); v->addSpacer( 0,100 ); }