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