pollymc/application/widgets/FocusLineEdit.cpp

26 lines
509 B
C++
Raw Normal View History

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