qlineedit

Add a click on QLineEdit

对着背影说爱祢 提交于 2020-01-11 07:07:51
问题 I am working on set a click() event to QLineEdit, I already successfully did it. But I want to go back to Mainwindow when the QLine Edit is clicked because I need the data in Mainwindow to further process the data. But I failed to let it go back, neither nor to cite the Mainwindow as parent, I hope someone can point it out. Thank you so much. MainWindow { ... self.tc = MyLineEdit(self.field[con.ConfigFields.VALUE])#self.tc = wx.TextCtrl(self.parent, -1, str(field[con.ConfigFields.VALUE]), pos

Add a click on QLineEdit

一曲冷凌霜 提交于 2020-01-11 07:07:30
问题 I am working on set a click() event to QLineEdit, I already successfully did it. But I want to go back to Mainwindow when the QLine Edit is clicked because I need the data in Mainwindow to further process the data. But I failed to let it go back, neither nor to cite the Mainwindow as parent, I hope someone can point it out. Thank you so much. MainWindow { ... self.tc = MyLineEdit(self.field[con.ConfigFields.VALUE])#self.tc = wx.TextCtrl(self.parent, -1, str(field[con.ConfigFields.VALUE]), pos

How to connect QLineEdit focusOutEvent

孤街醉人 提交于 2020-01-04 09:16:38
问题 I have designed a window with a QLineEdit in PyQt4 with the help of Designer. I converted .ui to .py using pyuic4 . I created another .py file and imported and subclassed Ui_Class . I want to perform some task when QLineEdit lost focus. Just line button clicked event i to connect QLineEdit Lost focus event 回答1: Use an eventFilter : class Filter(QtCore.QObject): def eventFilter(self, widget, event): # FocusOut event if event.type() == QtCore.QEvent.FocusOut: # do custom stuff print 'focus out'

How to set the PlaceHolderText for QTextEdit

假装没事ソ 提交于 2020-01-03 17:43:30
问题 I just want to set a PlaceHolderText for a QTextEdit . I know how to set it for a QLineEdit . There is a Property, setPlaceHolderText for QLineEdit. But this Property is not available for QTextEdit. Please give your valuable suggestions to solve this. 回答1: Use setTextCursor(QTextCursor&) function of QTextEdit. Use the following logic. QTextCursor textCursor; textCursor.setPosistion(0, QTextCursor::MoveAnchor); textedit->setTextCursor( textCursor ); 回答2: I was able to do this by subclassing

How to set the PlaceHolderText for QTextEdit

谁说我不能喝 提交于 2020-01-03 17:43:07
问题 I just want to set a PlaceHolderText for a QTextEdit . I know how to set it for a QLineEdit . There is a Property, setPlaceHolderText for QLineEdit. But this Property is not available for QTextEdit. Please give your valuable suggestions to solve this. 回答1: Use setTextCursor(QTextCursor&) function of QTextEdit. Use the following logic. QTextCursor textCursor; textCursor.setPosistion(0, QTextCursor::MoveAnchor); textedit->setTextCursor( textCursor ); 回答2: I was able to do this by subclassing

How to place an icon onto a QLineEdit?

烈酒焚心 提交于 2020-01-01 04:38:09
问题 There is a Search field with the magnification-lens and a greyed out "search" keyword at the top right corner of stackoverflow.com web site: I wonder if it is possible to achieve a same appearance with QLineEdit . If so then how? 回答1: Simple Way for Dummies Add a QLineEdit , and set it frameless by QLineEdit::setFrame Add a QLabel with background color in white (by stylesheet) and a icon Combine the line edit and the label with a layout, set spacing to 0 Set placeholder text with QLineEdit:

How to set Input Mask and QValidator to a QLineEdit at a time in Qt?

匆匆过客 提交于 2019-12-30 03:19:07
问题 I want a line edit which accepts an ip address. If I give input mask as: ui->lineEdit->setInputMask("000.000.000.000"); It is accepting values greater than 255. If I give a validator then we have to give a dot(.) after every three digits. What would the best way to handle it? 回答1: It is accepting value greater than 255. Absolutely, because '0' means this: ASCII digit permitted but not required. As you can see, this is not your cup of tea. There are at least the following ways to circumvent it

How can i get current focused QLineEdit in qt?

人盡茶涼 提交于 2019-12-23 18:27:12
问题 How can I identify which QLineEdit has the current focus in qt? To set the focus for QLinEdit I have tried: ui->linedit->setfocus(); but it also not working for me. How can I solve these two? 回答1: To identify which focused Widget (QlineEdit or any QWidget), you need to get all your current widget children, cast each to QLineEdit, and check which one has focus, sample code: QList<QWidget*> mylineEdits = this->findChildren<QWidget*>(); QListIterator<QWidget*> it(mylineEdits); // iterate through

Set properties of multiple QLineEdit using a loop

蹲街弑〆低调 提交于 2019-12-20 06:19:51
问题 I was wondering if it is possible to set multiple setFixedHeight() properties using a for loop: for num in range(1, 6): self.LineEdit[num].setFixedHeight() currently I have twelve QLineEdit boxes LineEdit1, LineEdit2, ... , LineEdit12 and I'm hoping to do this with less code. I tried the above method, and it did not iterate through the LineEdit boxes as I had expected. Would self.LineEdit[num] only work for a list? 回答1: for this task you can use getattr(): for i in range(1,13): getattr(self,

PyQt QLineEdit with QValidator

帅比萌擦擦* 提交于 2019-12-20 03:32:32
问题 I have a QLineEdit in my project. I want to use the QValidation on lineEdit. #Create lineEdit itemValue = QtWidgets.QLineEdit() #Create валидатор objValidator = QtGui.QDoubleValidator(self) #setup range objValidator.setRange(-10.0, 100.0, 5) #lineEdit with validation itemValue.setValidator(objValidator) But it doesn't work well.I can type what i want, except symbols. And range doesn't work!I can type 100500 or -100500, but i want, that user can enter numbers only in range. How i should use