[Qt-interest] Problems when using a QLineEdit

Gopalakrishna Bhat gopalakbhat at gmail.com
Mon Oct 25 09:54:13 CEST 2010


Hi,

For selecting all the text try

void MyLineEdit::mousePressEvent(QMouseEvent *event)
{
    if(!hasSelectedText()) {
           this->setCursorPosition(0);
           this->selectAll();
    } else {
          QLineEdit::mousePressEvent(event);
    }
}

With regards,
Gopalakrishna Bhat


On Mon, Oct 25, 2010 at 12:59 PM, NoRulez <norulez at me.com> wrote:
> Hello,
>
>
>
> I’ve some problems using a QLineEdit:
>
>
>
> 1.)    When clicking on the LineEdit the first time, then all text should be
> selected
>
> 2.)    If the LineEdit is small (maxWidth = 30) then the direction seems
> false (e.g. the text is “abcdefghijklmnopqrst”):
> Here I see “qrst” not “abcd”
>
>
>
> For 1.) I also tried to overload the focusInEvent() which won’t work:
>
> protected:
>
>       virtual void focusInEvent(QFocusEvent *e)
>
>       {
>
>             QLineEdit::focusInEvent(e);
>
>             selectAll();
>
>       }
>
>
>
> For 2.) I tried to set the layoutDirection, but this is “wrong” and doesn’t
> solve the problem
>
>
>
> I hope someone could help me
>
>
>
> Thanks in advance
>
> Best Regards
>
> NoRulez
>
>
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>



-- 
My blog http://gkbhat.blogspot.com




More information about the Qt-interest-old mailing list