¿Cómo puedo tener todo el texto seleccionado de forma predeterminada en mi edición de línea?
Frecuentes
Visto 204 veces
1
I'd like to be able to have all text highlighted in my lineEdit. However, the default selectAll() doesn't seem to do so.
import sys
from PyQt4 import QtCore, QtGui
from gui import Ui_Form
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Form()
self.ui.setupUi(self)
self.ui.lineEdit.setText("Type something here!")
self.ui.lineEdit.selectAll()
QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.ui.textEdit.clear)
QtCore.QObject.connect(self.ui.lineEdit, QtCore.SIGNAL("returnPressed()"), self.add_entry)
def add_entry(self):
self.ui.lineEdit.selectAll()
self.ui.lineEdit.cut()
self.ui.textEdit.append("")
self.ui.textEdit.paste()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())
I want to select the text on the lineEdit in the default constructor; however, it doesn't. Any reason for this? What should I be doing instead to accomplish this?
0 Respuestas
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas pyqt or haz tu propia pregunta.
¿Estás tratando de volver a implementar
placeholderText
? - Avaris@Avaris Yes! That was it, except it is setPlaceholderText(str) - Ci3