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
102
votes
6 answers

Set QLineEdit to accept only numbers

I have a QLineEdit where the user should input only numbers. So is there a numbers-only setting for QLineEdit?
sashoalm
  • 75,001
  • 122
  • 434
  • 781
57
votes
3 answers

Detecting enter on a QLineEdit or QPushButton

I've built an app for a game, simple to start. It's a game in which the system randomly chooses a number and a gamer (player) tries to find out the number. Everything is almost done. The app consists of a QLineEdit, a label and three buttons. Once…
arkero24
  • 669
  • 1
  • 5
  • 7
56
votes
4 answers

How to get text in QlineEdit when QpushButton is pressed in a string?

I am trying to implement a function. My code is given below. I want to get the text in lineedit with objectname 'host' in a string say 'shost' when the user clicks the pushbutton with name 'connect'. How can I do this? I tried and failed. How do I…
esafwan
  • 17,311
  • 33
  • 107
  • 166
31
votes
3 answers

Using QLineEdit for passwords

How can I make a QLineEdit suitable for entering passwords (i.e. it doesn't show what's entered), something like the follwing:
fafa
  • 539
  • 2
  • 7
  • 8
28
votes
4 answers

How to make a QLineEdit not editable in Windows

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…
Devolus
  • 21,661
  • 13
  • 66
  • 113
23
votes
4 answers

Set QLineEdit focus in Qt

I am having a qt question. I want the QLineEdit widget to have the focus at application startup. Take the following code for example: #include #include #include #include…
hyperboreean
  • 8,273
  • 12
  • 61
  • 97
23
votes
2 answers

How to restrict user input in QLineEdit in pyqt

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…
Rao
  • 2,902
  • 14
  • 52
  • 70
19
votes
4 answers

Qt Set Background Color of QLineEdit

I'm trying to change the background color of the QLineEdit and I can't figure it out at all. I tried using stylesheets originally like this QLineEdit *le = new QLineEdit(); le->setStyleSheet("background:#000;"); but that didn't do anything. I tried…
David Ludwig
  • 967
  • 2
  • 12
  • 26
18
votes
7 answers

How to place an icon onto a QLineEdit?

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?
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
18
votes
5 answers

python QLineEdit Text Color

I am trying to create a demonstration app to show how to change font colors. I can do it in QLabel and QTextEdit I have found no way to change the foreground text color for a QLineEdit. The only thing I've tried that does not throw an error…
Mike Sr
  • 511
  • 1
  • 5
  • 15
17
votes
4 answers

Select text of QLineEdit on focus

I have created a dialog using QtDesigner. There is a QLineEdit object in the dialog with some default content. When the dialog initializes and the focus goes to the QLineEdit, I want the default content to be auto selected, so once the user start…
GG.
  • 2,835
  • 5
  • 27
  • 34
17
votes
3 answers

Get the value from a QLineEdit

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));
SamuelNLP
  • 4,038
  • 9
  • 59
  • 102
16
votes
2 answers

PyQt4: combine textChanged and editingFinished for QLineEdit

Is there a way to combine textChanged and editingFinished for QLineEdit? The problem is that editingFinished is emitted even if I only move the cursor away from QLineEdit without any changes. Whereas I want to emit a signal only when any changes…
Ekaterina Mishina
  • 1,633
  • 5
  • 20
  • 23
13
votes
2 answers

How to connect the signal valueChanged from QLineEdit to a custom slot in Qt

I need to connect the valueChanged signal from QLineEdit to a custom slot programatically. I know how to do the connection by using Qt Designer and doing the connection with graphical interface but I would like to do it programmatically so I can…
fs_tigre
  • 10,650
  • 13
  • 73
  • 146
11
votes
1 answer

QLineEdit with QValidator: React to editing finished regardless of input validity?

QLineEdit has a signal QLineEdit::editingFinished that gets emitted when the user finished editing, for example by pressing enter. However if a validator or an input mask was set, then editingFinished only gets emitted if the input is valid. But how…
Stefan Pfeifer
  • 593
  • 6
  • 16
1
2 3
39 40