Migration of QtMvvm from github
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

30 lines
804 B

#include "sampleview.h"
#include "ui_sampleview.h"
#include <QtMvvmCore/Binding>
SampleView::SampleView(QtMvvm::ViewModel *viewModel, QWidget *parent) :
QMainWindow(parent),
_viewModel(static_cast<SampleViewModel*>(viewModel)),
ui(new Ui::SampleView)
{
Q_ASSERT(_viewModel);
ui->setupUi(this);
QtMvvm::bind(_viewModel, "active",
ui->activeCheckBox, "checked");
QtMvvm::bind(_viewModel, "name",
ui->nameLineEdit, "text",
QtMvvm::Binding::TwoWay,
nullptr,
"editingFinished()");
ui->eventsListView->setModel(_viewModel->eventsModel());
connect(ui->clearButton, &QPushButton::clicked,
_viewModel, &SampleViewModel::clearEvents);
connect(ui->resultButton, &QPushButton::clicked,
_viewModel, &SampleViewModel::getResult);
}
SampleView::~SampleView()
{
delete ui;
}