logplus/WellLogUI/include/completertextedit.h
2026-01-16 17:18:41 +08:00

43 lines
952 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// completertextedit.h
#ifndef COMPLETERTEXTEDIT_H
#define COMPLETERTEXTEDIT_H
#include <QTextEdit>
#include <QString>
#include "WellLogUI.h"
QT_BEGIN_NAMESPACE
class QCompleter;
QT_END_NAMESPACE
class OSGWELLLOGUI_EXPORT CompleterTextEdit : public QTextEdit
{
Q_OBJECT
public:
explicit CompleterTextEdit(QWidget *parent = 0);
~CompleterTextEdit()
{
// if(m_completer) delete m_completer;
}
void setCompleter(QCompleter *completer);
QCompleter * GetCompleter();
protected:
void keyPressEvent(QKeyEvent *e); // 响应按键盘事件
void keyReleaseEvent(QKeyEvent *e);
virtual void mousePressEvent(QMouseEvent *e);
private slots:
void onCompleterActivated(const QString &completion); // 响应选中QCompleter中的选项后QCompleter发出的activated()信号
private:
QString wordUnderCursor(); // 获取当前光标所在的单词
private:
QCompleter *m_completer;
};
#endif // COMPLETERTEXTEDIT_H1