29 lines
596 B
C++
29 lines
596 B
C++
//
|
|
// Created by Administrator on 2026/1/21.
|
|
//
|
|
|
|
#ifndef CLICKABLE_LINE_EDIT_H
|
|
#define CLICKABLE_LINE_EDIT_H
|
|
#include <QLineEdit>
|
|
#include <QMouseEvent>
|
|
|
|
class ClickableLineEdit : public QLineEdit {
|
|
Q_OBJECT
|
|
public:
|
|
ClickableLineEdit(QWidget *parent = nullptr) : QLineEdit(parent) {}
|
|
|
|
signals:
|
|
void clicked();
|
|
|
|
protected:
|
|
void mousePressEvent(QMouseEvent *event) override {
|
|
QLineEdit::mousePressEvent(event);
|
|
|
|
if (event->button() == Qt::LeftButton) {
|
|
emit clicked(); // 发射自定义信号
|
|
}
|
|
}
|
|
};
|
|
|
|
#endif //CLICKABLE_LINE_EDIT_H
|