123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- #include "VLineEdit.h"
- VLineEdit::VLineEdit(
- QWidget* parent,
- const QPoint& pos,
- const QSize& size,
- CONTROL_PROPERTY* pProperty
- )
- : QLineEdit(parent)
- , VControlObject(pProperty)
- {
- // 设置默认属性(初始化值或者外部传入值)
- if (m_Property.m_strText.isEmpty())
- {
- m_Property.m_strText = "LineEdit";
- }
- QLineEdit::setText(m_Property.m_strText);
- QLineEdit::setToolTip(m_Property.m_strTip);
- this->setTextColor(m_Property.m_clrText);
- this->setBgColor(m_Property.m_clrBg);
- QLineEdit::setFont(m_Property.m_Font);
- QLineEdit::setEnabled(m_Property.m_bEnable);
- // 设置尺寸
- if (size == DEFAULT_CONTROL_SIZE)
- {
- this->resize(DEFAULT_EDIT_SIZE);
- }
- else
- {
- this->resize(size);
- }
- // 设置中心点坐标
- QPoint tempPos;
- tempPos.setX(pos.x() - width() / 2);
- tempPos.setY(pos.y() - height() / 2);
- // 设置位置
- this->move(tempPos);
- m_pWidget = this;
- m_Type = VALUE_TYPE::Control_LineEdit;
- }
- VLineEdit::~VLineEdit()
- {
- }
- // 属性的实现函数
- void VLineEdit::setText(const QString& title/*, bool bForce*/)
- {
- if (this->m_Property.m_strText != title)
- {
- this->m_Property.m_strText = title;
- QLineEdit::setText(title);
- }
- //if (bForce)
- //{
- // QLineEdit::setText(title);
- //}
- }
- void VLineEdit::setTip(const QString& tip)
- {
- if (this->m_Property.m_strTip != tip)
- {
- this->m_Property.m_strTip = tip;
- QLineEdit::setToolTip(tip);
- }
- }
- void VLineEdit::setTextColor(const QColor& color)
- {
- QString qss = VControlObject::textColorQss(color);
- this->setStyleSheet(qss);
- }
- void VLineEdit::setBgColor(const QColor& color)
- {
- QString qss = VControlObject::bgColorQss(color);
- this->setStyleSheet(qss);
- }
- void VLineEdit::setFont(const QFont& font)
- {
- if (this->m_Property.m_Font != font)
- {
- this->m_Property.m_Font = font;
- QLineEdit::setFont(font);
- }
- }
- void VLineEdit::setEnable(const bool enable)
- {
- if (this->m_Property.m_bEnable != enable)
- {
- this->m_Property.m_bEnable = enable;
- QLineEdit::setEnabled(enable);
- }
- }
- ///// <summary>
- ///// 控件文字变更时,需要与Runtime与Dll三方同步
- ///// </summary>
- ///// <param name="strText"></param>
- //void VLineEdit::onTextChanged(const QString& strText)
- //{
- // // qDebug() << "VLineEdit::onTextChanged";
- //
- // Q_UNUSED(strText);
- //
- // g_pUiManager->syncToDll(this, UI_SYNC_MSG::EDIT_TEXT_CHANGED);
- //}
|