2016-01-12 03:37:30 +00:00
|
|
|
#include "FocusLineEdit.h"
|
|
|
|
#include <QDebug>
|
|
|
|
|
2023-08-02 17:35:35 +01:00
|
|
|
FocusLineEdit::FocusLineEdit(QWidget* parent) : QLineEdit(parent)
|
2016-01-12 03:37:30 +00:00
|
|
|
{
|
|
|
|
_selectOnMousePress = false;
|
|
|
|
}
|
|
|
|
|
2023-08-02 17:35:35 +01:00
|
|
|
void FocusLineEdit::focusInEvent(QFocusEvent* e)
|
2016-01-12 03:37:30 +00:00
|
|
|
{
|
|
|
|
QLineEdit::focusInEvent(e);
|
|
|
|
selectAll();
|
|
|
|
_selectOnMousePress = true;
|
|
|
|
}
|
|
|
|
|
2023-08-02 17:35:35 +01:00
|
|
|
void FocusLineEdit::mousePressEvent(QMouseEvent* me)
|
2016-01-12 03:37:30 +00:00
|
|
|
{
|
|
|
|
QLineEdit::mousePressEvent(me);
|
2023-08-02 17:35:35 +01:00
|
|
|
if (_selectOnMousePress) {
|
2016-01-12 03:37:30 +00:00
|
|
|
selectAll();
|
|
|
|
_selectOnMousePress = false;
|
|
|
|
}
|
|
|
|
qDebug() << selectedText();
|
|
|
|
}
|