|
@@ -1,5 +1,9 @@
|
|
|
#include "JReLineEdit.h"
|
|
|
#include "../SpeedAdjPage.h"
|
|
|
+#include <QGroupBox>
|
|
|
+#include <QComboBox>
|
|
|
+#include <QCheckBox>
|
|
|
+#include <qDebug>
|
|
|
|
|
|
JReLineEdit::JReLineEdit(QWidget* parent /*= nullptr*/)
|
|
|
: QLineEdit(parent)
|
|
@@ -11,14 +15,100 @@ void JReLineEdit::upDataValLine(const ST_DEF_VAL _val)
|
|
|
m_stSavedefVal = _val;
|
|
|
}
|
|
|
|
|
|
+void JReLineEdit::CheckVal()
|
|
|
+{
|
|
|
+ // 获取按钮所在的父窗口
|
|
|
+ QWidget* parentWindow = this->window();
|
|
|
+
|
|
|
+ QList<QGroupBox*> pListBox = parentWindow->findChildren<QGroupBox*>();
|
|
|
+ QList<QComboBox*> pListQComboBox = parentWindow->findChildren<QComboBox*>();
|
|
|
+ // 遍历所有QLineEdit
|
|
|
+ foreach(QGroupBox * p, pListBox)
|
|
|
+ {
|
|
|
+ if (p->objectName() == "axisGroupBox")
|
|
|
+ {
|
|
|
+ // 获取所有子控件
|
|
|
+ QList<QWidget*> children = p->findChildren<QWidget*>();
|
|
|
+
|
|
|
+ std::vector<ns_module::MODULE_COORD_MOVE> vecPos;
|
|
|
+ int nNum = 0;
|
|
|
+ // 总共没几个
|
|
|
+ ns_module::MODULE_COORD_MOVE axisPos = {};
|
|
|
+ foreach(QWidget * child, children)
|
|
|
+ {
|
|
|
+ if (child->metaObject()->className() == "QCheckBox")
|
|
|
+ {
|
|
|
+ QCheckBox* checkBox = qobject_cast<QCheckBox*>(child);
|
|
|
+ if (checkBox)
|
|
|
+ {
|
|
|
+ // 转换成功,可以安全使用 checkBox
|
|
|
+ if (checkBox->isChecked())
|
|
|
+ {
|
|
|
+ nNum += 1;
|
|
|
+ if (checkBox->objectName() == "forceCheckBox")
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (checkBox->objectName() == "forceCheckBox")
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (checkBox->objectName() == "forceCheckBox")
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (checkBox->objectName() == "forceCheckBox")
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 转换失败,widget 不是 QCheckBox 类型
|
|
|
+ //qDebug() << "该 widget 不是 QCheckBox";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 表示是另一个控件
|
|
|
+ if (nNum == 1)
|
|
|
+ {
|
|
|
+ QCheckBox* checkBox = qobject_cast<QCheckBox*>(child);
|
|
|
+
|
|
|
+ axisPos.pos = checkBox->text().toDouble();
|
|
|
+ vecPos.push_back(axisPos);
|
|
|
+ nNum = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ //qDebug() << "name :" << child->objectName()
|
|
|
+ // << " type::" << child->metaObject()->className();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取选中
|
|
|
+ foreach(QComboBox* p, pListQComboBox)
|
|
|
+ {
|
|
|
+ if (p->objectName() == "modeComboBox")
|
|
|
+ {
|
|
|
+ m_stSavedefVal.strMode = p->currentText();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SpeedAdjPage* pNew = new SpeedAdjPage();
|
|
|
+ pNew->updateDefVal(m_stSavedefVal);
|
|
|
+ pNew->show();
|
|
|
+}
|
|
|
+
|
|
|
void JReLineEdit::mousePressEvent(QMouseEvent* event)
|
|
|
{
|
|
|
if (event->button() == Qt::LeftButton)
|
|
|
{
|
|
|
- SpeedAdjPage* pNew = new SpeedAdjPage(this);
|
|
|
- pNew->updateDefVal(m_stSavedefVal);
|
|
|
- pNew->show();
|
|
|
+ CheckVal();
|
|
|
}
|
|
|
+
|
|
|
QLineEdit::mousePressEvent(event);
|
|
|
}
|
|
|
|