Questions tagged [qlineedit]

QLineEdit is a component of the Qt library which is basically a text editor that has only one line, and which allows one to make inputting and editing of text. A related class is QTextEdit which allows multi-line, rich text editing.

A minimalistic example of a QLineEdit that is shown in a new window, and contains the infamous "Hello, World!" line:

#include <QtGui>
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a( argc, argv );
    QLineEdit * myLine = new QLineEdit( "Hello, World!" );
    myLine->show();
    return a.exec();
}

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

600 questions
7
votes
3 answers

Change the Color and Font of QString or QLineEdit

How can I change the color and font of QLineEdit? Here is my code: self.lineEdit = QtGui.QLineEdit(widget) self.lineEdit.setText("enter keywords here") #I want this to be in italics and in brown color The setText line from Documentation says the…
learncode
  • 1,105
  • 4
  • 18
  • 36
7
votes
7 answers

Change color of placeholder text in QLineEdit

When I set the placeholder text with QLineEdit::setPlaceholderText(), it appears gray. Is there any way to change the color to something else, for example red?
Programming
  • 143
  • 1
  • 2
  • 10
7
votes
3 answers

QLineEdit: Set cursor location to beginning on focus

I have a QLineEdit with an input mask, so that some kind of code can easily be entered (or pasted). Since you can place the cursor anywhere in the QLineEdit even if there is no text (because there is a placeholder from the input mask): If people…
Joey
  • 344,408
  • 85
  • 689
  • 683
7
votes
1 answer

How to read out the text from QLineEdit in python?

I have created for my plugin a start GUI with 3 buttons. This works very well and if I click on one of the buttons a specific action is started. So far this works. If I click on one of the buttons a new GUI with two buttons "ok" and "cancel" and a…
Sven
  • 195
  • 1
  • 1
  • 4
6
votes
2 answers

QLineEdit Accepts Only Character in PyQt4

I have written a method that validate characters in the lineEdit: def is_validate(self): regex = QtCore.QRegExp("[a-z-A-Z_]+") txtDepartment_validator = QtGui.QRegExpValidator(regex, self.txtDepartment) …
Cahit Yıldırım
  • 499
  • 1
  • 10
  • 26
6
votes
2 answers

Adjusting QLineEdit's default width

I'm trying my hand at writing a sudoku solver, what I am currently trying to achieve is the input of a sudoku into a grid of 9 by 9 QLineEdit fields. The grid is constructed by using a grid of 9 QFrames which each hold a grid of 9 subclassed…
mr_kazz
  • 91
  • 1
  • 5
6
votes
1 answer

Qt code does not compile when i try to connect one signal to a slot

I'm new to Qt. I'm trying to implement a really simple calculator program. Just trying to put a button, and when its clicked, i want it to print "Hello, World!" to the next lineEdit. It is working fine when i have only one button, but when I add the…
arikan
  • 893
  • 9
  • 18
6
votes
1 answer

Qt (C++): Add background text in line edit

I want to be able to add a line of (grey) text that when you type in the line edit, goes away. So the text is not actually there, it is just displayed. For example: Before I type something, the grey background text is…
6
votes
1 answer

Get the text margins of a QLineEdit

How can I get the text margins for a QLineEdit? Note the red lines in the screenshot, that's the margins I'm interested in: I tried qDebug() << ui->lineEdit->textMargins(); for the edit box from the screenshot, but it printed QMargins(0, 0, 0, 0),…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
6
votes
8 answers

Allow entry in QLineEdit only within range of QDoubleValidator

I have a set of QLineEdits that are supposed to accept double values within a certain range, (e.g., -15 to 15). I have something along these lines when setting up each: lineEdit->setValidator(new QDoubleValidator(minVal, maxVal, 5,…
norman
  • 5,128
  • 13
  • 44
  • 75
6
votes
6 answers

How to insert a button inside a QLineEdit

I need help inserting a button inside in a QLineEdit that can call a function. For example, like this google image:
Andrew Zhuk
  • 500
  • 8
  • 23
5
votes
1 answer

Change ClearButton Icon of QLineEdit

I want to change the ClearButton icon of my QLineEdit at Python 3.8 and PyQt5 (5.15.0) on Windows 10 (1909, 64-bit), later on I want to run the code on Linux. I've tried to apply the code found here: How to make an extra icon in QLineEdit like…
David
  • 65
  • 10
5
votes
2 answers

QLineEdit: Show a processed text, not the entered one, but keep it (custom echo mode)

I want a QLineEdit not to display the entered text, but a processed version, while keeping the original text and returning it when it's requested via text(). Like with the password echo mode, but I don't want each character to be masked. I want to…
Tobias Leupold
  • 1,512
  • 1
  • 16
  • 41
5
votes
1 answer

Python: How to enable button if the QlineEdit is Filled

Can someone tell me what approach or what logic so the QPushbutton will be enable if all the fields are not empty. I'm making a simple form that you can only push the button if the fields are not empty. class Ui_MainWindow(object): def…
5
votes
1 answer

I use QDoubleValidator in my pyqt5 program but it doesn't seem to work

I make a QWidget object in which there are some lineEdits and I intend to add some constraints to them, so I implement QDoubleValidator objects. Following is the related part in my code. self.lineEdit_taxRate=…
Travis
  • 55
  • 1
  • 6
1 2
3
39 40