AddSchemeWidget.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "AddSchemeWidget.h"
  2. #include <Widgets/Button.h>
  3. #include <Widgets/LineEdit.h>
  4. #include <QBoxLayout>
  5. #include <QLabel>
  6. AddSchemeWidget::AddSchemeWidget(QWidget *parent) : QDialog(parent)
  7. {
  8. initWindow();
  9. initialize();
  10. initLayout();
  11. connectSignalsAndSlots();
  12. }
  13. void AddSchemeWidget::clearInputs()
  14. {
  15. m_nameEdit->clear();
  16. m_schemeEdit->clear();
  17. }
  18. void AddSchemeWidget::initWindow()
  19. {
  20. setWindowTitle("新建方案");
  21. setModal(true);
  22. setWindowFlags(Qt::Dialog);
  23. setWindowFlag(Qt::WindowContextHelpButtonHint, false);
  24. resize(350, 250);
  25. }
  26. void AddSchemeWidget::initialize()
  27. {
  28. m_vBoxLayout = new QVBoxLayout(this);
  29. m_gridLayout = new QGridLayout();
  30. m_nameLabel = new QLabel("方案名称:", this);
  31. m_nameLabel->setFixedHeight(44);
  32. m_nameEdit = new LineEdit(this);
  33. m_nameEdit->setFixedWidth(250);
  34. m_schemeLabel = new QLabel("方案描述:", this);
  35. m_schemeLabel->setFixedHeight(35);
  36. m_schemeEdit = new TextEdit(this);
  37. m_schemeEdit->setFixedWidth(250);
  38. m_schemeEdit->setFixedHeight(150);
  39. m_hBoxLayout = new QHBoxLayout();
  40. m_confirButton = new PushButton("生成", this);
  41. }
  42. void AddSchemeWidget::initLayout()
  43. {
  44. m_vBoxLayout->setMargin(15);
  45. m_vBoxLayout->addLayout(m_gridLayout);
  46. m_gridLayout->addWidget(m_nameLabel, 0, 0, 1, 1, Qt::AlignRight);
  47. m_gridLayout->addWidget(m_nameEdit, 0, 1, 1, 2, Qt::AlignLeft);
  48. m_gridLayout->addWidget(m_schemeLabel, 1, 0, 1, 1, Qt::AlignRight | Qt::AlignTop);
  49. m_gridLayout->addWidget(m_schemeEdit, 1, 1, 1, 2, Qt::AlignLeft);
  50. m_vBoxLayout->addSpacing(20);
  51. m_vBoxLayout->addStretch();
  52. m_vBoxLayout->addLayout(m_hBoxLayout);
  53. m_hBoxLayout->addStretch();
  54. m_hBoxLayout->addWidget(m_confirButton);
  55. }
  56. void AddSchemeWidget::connectSignalsAndSlots() { }