문제

I have a Qlineedit widget which i will use to accept the username. It will be displayed as soon as user launch the application. I want the Qlineedit widget ready for typing (ie, with cursor already in place) without needing the user to use mouse to click on the widget before typing.

I have tried .setFocus() and .setCursorPosition(1) but doesn't seem to work.

Which method should i use to set the cursor at the starting position of Qlineedit without user needing to click on it?

도움이 되었습니까?

해결책

It was my mistake. I was trying to use setFocus before i add the widget to the layout.

Now, I used the setFocus method after the wiget is added to the layout and it works fine.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top