Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个表单布局,我在其中使用QLineEdit(self).setPlaceholderText("Write your name"). 我正在写值并按下“确定”按钮,然后我需要将此值打印到屏幕上。我该怎么做?
QLineEdit(self).setPlaceholderText("Write your name")
您需要保留对 lineedit 的引用,以便以后可以询问它有什么内容。
放入您的代码中:
self.q = QtGui.QLineEdit(self) self.q.setPlaceholderText("Write your name") # user does their thing print( self.q.text() )
最后一行当然是你处理按下 OK 按钮的地方。