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