EvalWidget.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "EvalWidget.h"
  2. #include <QLabel>
  3. #include <QLayout>
  4. #include <QDebug>
  5. EvalWidget::EvalWidget(int type, QWidget *parent) : QWidget(parent), m_type(type)
  6. {
  7. initWidgets();
  8. initLayout();
  9. }
  10. int EvalWidget::type() const
  11. {
  12. return m_type;
  13. }
  14. void EvalWidget::setType(int type)
  15. {
  16. m_type = type;
  17. }
  18. void EvalWidget::setTitle(const QString title)
  19. {
  20. m_title->setText(title);
  21. }
  22. void EvalWidget::initWidgets()
  23. {
  24. m_title = new QLabel(this);
  25. QFont ft("Microsoft YaHei", 12);
  26. m_title->setFont(ft);
  27. // 分割线
  28. m_seperator = new QWidget(this);
  29. m_seperator->setFixedHeight(1);
  30. QPalette pal(m_seperator->palette());
  31. pal.setColor(QPalette::Background, QColor("#aaaaaa"));
  32. m_seperator->setAutoFillBackground(true);
  33. m_seperator->setPalette(pal);
  34. }
  35. void EvalWidget::initLayout()
  36. {
  37. m_layout = new QVBoxLayout(this);
  38. m_contentLayout = new QVBoxLayout();
  39. m_layout->addWidget(m_title);
  40. m_layout->addWidget(m_seperator);
  41. m_layout->addLayout(m_contentLayout);
  42. m_layout->addStretch();
  43. }