mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 16:40:42 +08:00
Add QClearLineEdit.
Which emits 'returnPressed' on clear action.
This commit is contained in:
@@ -88,6 +88,7 @@ set(HEADER_FILES
|
||||
QDetachTabWidget.h
|
||||
QZoomChartView.h
|
||||
QZoomChart.h
|
||||
QClearLineEdit.h
|
||||
)
|
||||
|
||||
set(SOURCE_FILES
|
||||
@@ -161,6 +162,7 @@ set(SOURCE_FILES
|
||||
QDetachTabWidget.cpp
|
||||
QZoomChartView.cpp
|
||||
QZoomChart.cpp
|
||||
QClearLineEdit.cpp
|
||||
)
|
||||
|
||||
qt5_add_resources(SOURCE_FILES resource.qrc)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "QClearLineEdit.h"
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
QClearLineEdit::QClearLineEdit (const QString& contents, QWidget* parent) : QLineEdit(contents, parent) {
|
||||
|
||||
enableReturnPressedOnClear();
|
||||
}
|
||||
|
||||
QClearLineEdit::QClearLineEdit (QWidget* parent) : QLineEdit(parent) {
|
||||
|
||||
enableReturnPressedOnClear();
|
||||
}
|
||||
|
||||
QClearLineEdit::~QClearLineEdit () {
|
||||
}
|
||||
|
||||
void QClearLineEdit::enableReturnPressedOnClear() {
|
||||
|
||||
for (int i=0; i <children().size(); i++) {
|
||||
|
||||
QAction* myClearAction(qobject_cast<QAction*>(children().at(i)));
|
||||
|
||||
if (myClearAction) {
|
||||
|
||||
//qDebug() << myClearAction->objectName();
|
||||
|
||||
// Look for only the QLineEdit clear action.
|
||||
// This name could change or be different.
|
||||
if (myClearAction->objectName() == "_q_qlineeditclearaction") {
|
||||
connect(myClearAction, &QAction::triggered, this, &QLineEdit::returnPressed, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QAction>
|
||||
|
||||
class QClearLineEdit : public QLineEdit {
|
||||
|
||||
public:
|
||||
QClearLineEdit (const QString& contents, QWidget* parent = nullptr);
|
||||
QClearLineEdit (QWidget* parent = nullptr);
|
||||
~QClearLineEdit ();
|
||||
|
||||
void enableReturnPressedOnClear ();
|
||||
|
||||
public slots:
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -49,6 +49,9 @@ SeerArrayVisualizerWidget::SeerArrayVisualizerWidget (QWidget* parent) : QWidget
|
||||
handleaArrayDisplayFormatComboBox(0);
|
||||
handlebArrayDisplayFormatComboBox(0);
|
||||
|
||||
aVariableNameLineEdit->enableReturnPressedOnClear();
|
||||
bVariableNameLineEdit->enableReturnPressedOnClear();
|
||||
|
||||
// A single series chart.
|
||||
QChart* chart = new QChart;
|
||||
chart->legend()->hide();
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="bVariableNameLineEdit">
|
||||
<widget class="QClearLineEdit" name="bVariableNameLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Variable name or expression.</string>
|
||||
</property>
|
||||
@@ -286,7 +286,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="aVariableNameLineEdit">
|
||||
<widget class="QClearLineEdit" name="aVariableNameLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Variable name or expression.</string>
|
||||
</property>
|
||||
@@ -497,7 +497,12 @@
|
||||
<customwidget>
|
||||
<class>QZoomChartView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header>QZoomChartView.h</header>
|
||||
<header location="global">QZoomChartView.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QClearLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">QClearLineEdit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
|
||||
Reference in New Issue
Block a user