简体   繁体   中英

Tkinter .focus_set() equivalent in PyQt4

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM