VTextEdit.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "VTextEdit.h"
  2. VTextEdit::VTextEdit(QWidget *parent, CONTROL_PROPERTY* pProperty)
  3. : QTextEdit(parent)
  4. , VControlObject(pProperty)
  5. {
  6. // 设置默认属性(初始化值或者外部传入值)
  7. QTextEdit::setText(m_Property.m_strText);
  8. QTextEdit::setToolTip(m_Property.m_strTip);
  9. this->setTextColor(m_Property.m_clrText);
  10. this->setBgColor(m_Property.m_clrBg);
  11. QTextEdit::setFont(m_Property.m_Font);
  12. QTextEdit::setEnabled(m_Property.m_bEnable);
  13. }
  14. VTextEdit::~VTextEdit()
  15. {
  16. }
  17. // 属性的实现函数
  18. void VTextEdit::setText(const QString& title)
  19. {
  20. qDebug() << m_Property.m_strText;
  21. if (this->m_Property.m_strText != title)
  22. {
  23. this->m_Property.m_strText = title;
  24. QTextEdit::setText(title);
  25. }
  26. }
  27. void VTextEdit::setTip(const QString& tip)
  28. {
  29. if (this->m_Property.m_strTip != tip)
  30. {
  31. this->m_Property.m_strTip = tip;
  32. QTextEdit::setToolTip(tip);
  33. }
  34. }
  35. void VTextEdit::setTextColor(const QColor& color)
  36. {
  37. QString qss = VControlObject::textColorQss(color);
  38. this->setStyleSheet(qss);
  39. }
  40. void VTextEdit::setBgColor(const QColor& color)
  41. {
  42. QString qss = VControlObject::bgColorQss(color);
  43. this->setStyleSheet(qss);
  44. }
  45. void VTextEdit::setFont(const QFont& font)
  46. {
  47. if (this->m_Property.m_Font != font)
  48. {
  49. this->m_Property.m_Font = font;
  50. QTextEdit::setFont(font);
  51. }
  52. }
  53. void VTextEdit::setEnable(const bool enable)
  54. {
  55. if (this->m_Property.m_bEnable != enable)
  56. {
  57. this->m_Property.m_bEnable = enable;
  58. QTextEdit::setEnabled(enable);
  59. }
  60. }