문제

In my Qt application, when the text width in the QLineEdit widget is greater than widget width, it seems QLineEdit can only display the right part of text (see below). No matter I set the widget to right alignment, or set cursor position to maxTextLength. I will have to click in the QLineEdit text box and hit Home to see the left part. Is it possible to have the left part displayed by default?

For example:
The text is "abcdefghijklmnopqrstuvwxyz" (26 characters), and the QLineEdit width is 11-character.

Right part displayed (pqrstuvwxyz):

               [ line edit ]
 abcdefghijklmnopqrstuvwxyz

Left part displayed (abcdefghijk):

[ line edit ]
 abcdefghijklmnopqrstuvwxyz
도움이 되었습니까?

해결책

Found the solution. Using void QLineEdit::home(bool mark).

다른 팁

Also you can apply stylesheet for QLineEdit with zero cursor position:

lineEdit->setStyleSheet("QLineEdit { qproperty-cursorPosition: 0; }");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top