Qt Quick based coffee brewing control chart.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

newpointcontrol.cpp 1.3KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include <QBoxLayout>
  2. #include <QFormLayout>
  3. #include <QLineEdit>
  4. #include <QPushButton>
  5. #include "newpointcontrol.h"
  6. NewPointControl::NewPointControl(QWidget *parent) :
  7. QWidget(parent), groundsMass(new QLineEdit), brewMass(new QLineEdit),
  8. tds(new QLineEdit)
  9. {
  10. QVBoxLayout *layout = new QVBoxLayout;
  11. QFormLayout *flayout = new QFormLayout;
  12. QPushButton *plot = new QPushButton(tr("Plot"));
  13. flayout->addRow(tr("Mass of ground coffee:"), groundsMass);
  14. flayout->addRow(tr("Mass of brewed coffee:"), brewMass);
  15. flayout->addRow(tr("% total dissolved solids:"), tds);
  16. layout->addLayout(flayout);
  17. layout->addWidget(plot);
  18. layout->addStretch();
  19. setLayout(layout);
  20. connect(plot, SIGNAL(clicked()), this, SLOT(plotButtonClicked()));
  21. }
  22. void NewPointControl::plotButtonClicked()
  23. {
  24. QVariantMap pointDescription;
  25. pointDescription.insert("groundMass", groundsMass->text());
  26. pointDescription.insert("brewedMass", brewMass->text());
  27. pointDescription.insert("ptds", tds->text());
  28. pointDescription.insert("color", "red");
  29. double extraction = (brewMass->text().toDouble() *
  30. (tds->text().toDouble() / 100)) /
  31. groundsMass->text().toDouble();
  32. pointDescription.insert("extraction", extraction);
  33. emit newPoint(pointDescription);
  34. }