将焦点设置在Qt中的QLineEdit
控件上,可以使用setFocus()
方法。以下是一个简单的示例:
from PyQt5.QtWidgets import QApplication, QLineEdit
app = QApplication([])
line_edit = QLineEdit()
line_edit.setFocus()
app.exec_()
在这个示例中,我们首先导入了PyQt5
库中的QApplication
和QLineEdit
模块。然后创建了一个QLineEdit
对象,并使用setFocus()
方法将焦点设置在该对象上。最后,我们使用app.exec_()
方法启动应用程序。
领取专属 10元无门槛券
手把手带您无忧上云