qlineedit

How to display Arabic notations in left-to-right direction in QLineEdit/QLabel etc.?

不羁岁月 提交于 2019-12-03 21:40:52
In Qt's implementation arabic notation is shown in right-to-left direction, thus any strings that contain arabic notations will be right-aligned. But what my application wants to do is showing all texts in left-to-right direction, whether it contains arabic notations or not. And all texts are left-aligned. An example is shown below: This is what I want to implement This is how QLineEdit displays texts containing arabic notations in its default way This is how QLabel does it EDIT: Paste the test string here. ە抠门哥ە( EDIT: Providing an alternate solution. Finally I can achieve my goal roughly by

How to restrict user input in QLineEdit in pyqt

淺唱寂寞╮ 提交于 2019-12-03 17:20:24
问题 I have a QLineEdit and i want to restrict QLineEdit to accept only integers. It should work like inputmask. But I dont want to use inputmask , because if user clicks on QLineEdit cursor will be at the position where mouse was clicked. and user need to navigate to 0 position and type what eve he wants. Is there any alternate for this. 回答1: you can use QValidator it works like: #To allow only int self.onlyInt = QIntValidator() self.LineEdit.setValidator(self.onlyInt) 回答2: you can use exception

How to make a QLineEdit not editable in Windows

元气小坏坏 提交于 2019-12-03 16:17:02
问题 I'm using Qt 5.2 and I would like to make a QLineEdit not editable. The problem with this is, that it doesn't appear like it. When using setReadOnly(true) it stays with white background and looks like it is still editable. If I disable it, then it turns gray and the text also gets a lighter gray. The problem is, that one can not copy the text from it, in a disabled state. So how can I make a QLineEdit properly non-editable and also make it look like it. In Windows such a control is usually

How to place an icon onto a QLineEdit?

别等时光非礼了梦想. 提交于 2019-12-03 12:07:06
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? Tay2510 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::setPlaceholderText Result Advanced Way Check this thread: "Can QLineEdit do this?" And the related

Get the value from a QLineEdit

十年热恋 提交于 2019-12-03 10:32:18
I have a QLineEdit that only allows numbers and I want to get the current value from it. I can't figure out how. ui->lineEdit->setValidator(new QIntValidator(this)); I figured it out: QString XMAX=ui->lineEdit->text(); xMax=XMAX.toDouble(); Or std::stod(ui->lineEdit->text().toStdString()); but watch out for the encoding. Samuel Ives Try this: ui->leNome->displayText() 来源: https://stackoverflow.com/questions/12161082/get-the-value-from-a-qlineedit

How to restrict user input in QLineEdit in pyqt

↘锁芯ラ 提交于 2019-12-03 06:19:02
I have a QLineEdit and i want to restrict QLineEdit to accept only integers. It should work like inputmask. But I dont want to use inputmask , because if user clicks on QLineEdit cursor will be at the position where mouse was clicked. and user need to navigate to 0 position and type what eve he wants. Is there any alternate for this. you can use QValidator it works like: #To allow only int self.onlyInt = QIntValidator() self.LineEdit.setValidator(self.onlyInt) you can use exception handling for validating this: number = self.ui.number_lineEdit.text() try: number = int(number) except Exception:

Set QLineEdit to accept only numbers

懵懂的女人 提交于 2019-12-03 04:40:58
问题 I have a QLineEdit where the user should input only numbers. So is there a numbers-only setting for QLineEdit ? 回答1: QLineEdit::setValidator() , for example: myLineEdit->setValidator( new QIntValidator(0, 100, this) ); or myLineEdit->setValidator( new QDoubleValidator(0, 100, 2, this) ); See: QIntValidator, QDoubleValidator, QLineEdit::setValidator 回答2: The best is QSpinBox. And for a double value use QDoubleSpinBox. QSpinBox myInt; myInt.setMinimum(-5); myInt.setMaximum(5); myInt

Set QLineEdit to accept only numbers

元气小坏坏 提交于 2019-12-02 17:48:41
I have a QLineEdit where the user should input only numbers. So is there a numbers-only setting for QLineEdit ? Chris QLineEdit::setValidator() , for example: myLineEdit->setValidator( new QIntValidator(0, 100, this) ); or myLineEdit->setValidator( new QDoubleValidator(0, 100, 2, this) ); See: QIntValidator , QDoubleValidator , QLineEdit::setValidator ImmortalPC The best is QSpinBox . And for a double value use QDoubleSpinBox . QSpinBox myInt; myInt.setMinimum(-5); myInt.setMaximum(5); myInt.setSingleStep(1);// Will increment the current value with 1 (if you use up arrow key) (if you use down

Set properties of multiple QLineEdit using a loop

若如初见. 提交于 2019-12-02 07:47:26
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? for this task you can use getattr() : for i in range(1,13): getattr(self, "LineEdit{}".format(i)).setFixedHeight(10) You may use findChildren() function. e.g. for ctl in self

Can QWidget detect mouse events on behalf of a QLineEdit?

倾然丶 夕夏残阳落幕 提交于 2019-12-02 03:34:49
I have a QWidget that contains QLabels and QLineEdits side by side. When I click on a QLabel, I can use the mousePressEvent in QWidget. But when I click on QLineEdit, I can't detect the mousePressEvent in QWidget - only in the QLineEdit. I think that it is related to how QLineEdit works - I don't know the way to get mouse events within the whole region. EDIT : I have made a custom channel box for Maya like above. I try to select multiple channels by dragging the mouse. But as I mentioned, in the QLineEdit regions I can't do this. class channelWidget(QtGui.QWidget): def __init__(self, parent