Qt-interest Archive, August 2007
QLineEdit and cursor position
Message 1 in thread
Hello,
I want select text in a QLineEdit and move the cursor to the first
characher without unselect the text.
The easy solution using QLineEdit::selectAll and
QLineEdit::setCursorPosition doesn't work, because setCursorPosition
unselect the text and selectAll moves the cursor to the end.
Is there a solution to this problem?
Thanks.
#include <qapplication.h>
#include <qapplication.h>
#include <qlineedit.h>
#include <qstring.h>
int main(int argc, char** argv){
QApplication qapp(argc, argv);
QString* msg = new QString("Do not feed the trolls!!!!!!!!!!!!!!!!!!!!!!");
QLineEdit* ql = new QLineEdit(NULL);
ql->setText(*msg);
ql->selectAll();
ql->setCursorPosition(0);
qapp.setMainWidget(ql);
ql->show();
return qapp.exec();
}
Message 2 in thread
Hello,
If your are using Qt 4.X, you might use :
QLineEdit::setSelection( 6, -4);
for example, to select backward four characters starting at the sixth.
Cheers
>>> Romain Jacquet <romain.jacquet@xxxxxxxxxxx> 09.08.2007 18:05 >>>
Hello,
I want select text in a QLineEdit and move the cursor to the first
characher without unselect the text.
The easy solution using QLineEdit::selectAll and
QLineEdit::setCursorPosition doesn't work, because setCursorPosition
unselect the text and selectAll moves the cursor to the end.
Is there a solution to this problem?
Thanks.
--
[ signature omitted ]
Message 3 in thread
Unfortunately, I'm using Qt 3.3 and I could not move to Qt 4 easily.
Is there no possibility with Qt 3.x?
Samuel Gaist a écrit :
> Hello,
>
> If your are using Qt 4.X, you might use :
> QLineEdit::setSelection( 6, -4);
>
> for example, to select backward four characters starting at the sixth.
>
> Cheers
>
>
>>>> Romain Jacquet <romain.jacquet@xxxxxxxxxxx> 09.08.2007 18:05 >>>
>>>>
> Hello,
>
>
> I want select text in a QLineEdit and move the cursor to the first
> characher without unselect the text.
>
> The easy solution using QLineEdit::selectAll and
> QLineEdit::setCursorPosition doesn't work, because setCursorPosition
> unselect the text and selectAll moves the cursor to the end.
>
> Is there a solution to this problem?
>
> Thanks.
>
>
>
>
>
>
>
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>
>
--
[ signature omitted ]
Message 4 in thread
In that case, and it's a wild guess, did you try "void
QLineEdit::cursorBackward ( bool mark, int steps = 1 )" ?
Looking in the doc, it might be just what you need with mark = TRUE.
>>> Romain Jacquet <romain.jacquet@xxxxxxxxxxx> 10.08.2007 09:18 >>>
Unfortunately, I'm using Qt 3.3 and I could not move to Qt 4 easily.
Is there no possibility with Qt 3.x?
Samuel Gaist a Ãcrit :
> Hello,
>
> If your are using Qt 4.X, you might use :
> QLineEdit::setSelection( 6, -4);
>
> for example, to select backward four characters starting at the
sixth.
>
> Cheers
>
>
>>>> Romain Jacquet <romain.jacquet@xxxxxxxxxxx> 09.08.2007 18:05 >>>
>>>>
> Hello,
>
>
> I want select text in a QLineEdit and move the cursor to the
first
> characher without unselect the text.
>
> The easy solution using QLineEdit::selectAll and
> QLineEdit::setCursorPosition doesn't work, because setCursorPosition
> unselect the text and selectAll moves the cursor to the end.
>
> Is there a solution to this problem?
>
> Thanks.
>
>
>
>
>
>
>
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>
>
--
[ signature omitted ]
Message 5 in thread
It works perfect!
Thanks for help.
Samuel Gaist a Ãcrit :
> In that case, and it's a wild guess, did you try "void
> QLineEdit::cursorBackward ( bool mark, int steps = 1 )" ?
> Looking in the doc, it might be just what you need with mark = TRUE.
>
>
>>>> Romain Jacquet <romain.jacquet@xxxxxxxxxxx> 10.08.2007 09:18 >>>
>>>>
> Unfortunately, I'm using Qt 3.3 and I could not move to Qt 4 easily.
> Is there no possibility with Qt 3.x?
>
> Samuel Gaist a Ãcrit :
>
>> Hello,
>>
>> If your are using Qt 4.X, you might use :
>> QLineEdit::setSelection( 6, -4);
>>
>> for example, to select backward four characters starting at the
>>
> sixth.
>
>> Cheers
>>
>>
>>
>>>>> Romain Jacquet <romain.jacquet@xxxxxxxxxxx> 09.08.2007 18:05 >>>
>>>>>
>>>>>
>> Hello,
>>
>>
>> I want select text in a QLineEdit and move the cursor to the
>>
> first
>
>> characher without unselect the text.
>>
>> The easy solution using QLineEdit::selectAll and
>> QLineEdit::setCursorPosition doesn't work, because setCursorPosition
>>
>
>
>> unselect the text and selectAll moves the cursor to the end.
>>
>> Is there a solution to this problem?
>>
>> Thanks.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
>>
> with "unsubscribe" in the subject or the body.
>
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>
>
>>
>>
>>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>
>
--
[ signature omitted ]