[Qt-interest] Problems when using a QLineEdit

NoRulez norulez at me.com
Mon Oct 25 15:21:36 CEST 2010


Thank you very much,

this seems to solve Problem 1.)

Best Regards
NoRulez


-----Ursprüngliche Nachricht-----
Von: Gopalakrishna Bhat [mailto:gopalakbhat at gmail.com] 
Gesendet: Montag, 25. Oktober 2010 09:54
An: NoRulez
Cc: qt-interest at trolltech.com
Betreff: Re: [Qt-interest] Problems when using a QLineEdit

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