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
3
votes
2 answers

Showing tooltip of QLineEdit upon focus in Qt

I found that I can set a tooltip on a QLineEdit as such: equation = new QLineEdit(); equation->setToolTip("Example: a*b+c+~c"); However, I would like the tooltip to be displayed when that QLineEdit is focused. How do I do that? Thanks in advance.
Gezim
  • 7,112
  • 10
  • 62
  • 98
3
votes
2 answers

Setting all QLineEdits to readOnly

I am trying to make all of my QLineEdits(I have about 150) read-only, is there a way to do this without going through and setting each individually? I was hoping I could do something like QLineEdit::setReadOnly(true); in my constructor but I get a…
user2494298
  • 299
  • 3
  • 7
  • 23
3
votes
4 answers

How to restrict the expression in QLineEdit

I need a QLineEdit which must represent a range. F.E. (1,2] , and for this representation I want to set a validation checker for user not to write other symbols. In this case I have char + int + char + int + char as shown in example below. Does Qt…
Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76
3
votes
3 answers

how to draw a line between items of a QCompleter as a separator?

I have a QCompleter and a QStringListModel that is set to QCompleter. Now how can I draw a line as separator between items of StringList that is set to QStringListModel. Finally, QCompleter will be set to a QLineEdit.
3
votes
1 answer

Some QLineEdit questions

I'm using Python with PyQt and I have a few problems with my QLineEdits. First of all, I want to put text on them, but not the regular one, I mean the transparent text that disappears when you click on the QLineEdit. How can I disable clicking on…
Antoni4040
  • 2,297
  • 11
  • 44
  • 56
3
votes
0 answers

QLineEdit undo/redo functionality interferes with global undo/redo

In the app I'm building, I've implemented a global undo/redo system that's accessible via the normal shortcut keys Ctrl-Z and Ctrl-Shift-Z. I'm also using QLineEdit fields which have an undo/redo function of their own. Whenever an editingFinished…
Michael Clerx
  • 2,928
  • 2
  • 33
  • 47
3
votes
1 answer

QLineEdit cursor moves to end after textChanged() or commitData()

I have a QTableView with one column that uses a QLineEdit as its editor delegate, and other columns that need to update dynamically as the user types into the QLineEdit (e.g. one of the columns contains the length of the text typed in the QLineEdit…
Jettoblack
  • 125
  • 3
  • 8
3
votes
2 answers

C++ QLineEdit: setmaxlength() for number of bytes and not the number of the characters?

I have a QLineEdit in my application in which I should be able to enter a maximum of 10byte characters in english and while entering Japanese characters , if the character is of 2byte , I should be able to enter only 5 characters in japanese and if…
skg
  • 948
  • 2
  • 19
  • 35
3
votes
1 answer

Can QWidget detect mouse events on behalf of a QLineEdit?

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…
Hyun-geun Kim
  • 919
  • 3
  • 22
  • 37
3
votes
2 answers

QLineEdit could not set shortcuts when it's in focus

I'm implementing a text-based to-do program. I have a CommandInput widget which inherits from QLineEdit. Basically there are a few commands, starting with keywords "add", "delete", "edit", and a few more. I want to implement a few shortcuts. Ctrl+A…
Vincent Li
  • 55
  • 1
  • 6
3
votes
1 answer

Alternative to QLineEdit to get a double

I have a QLineEdit which I use to get a double. But is there a more suitable way to get it? Here it is my code. ui->lineEdit->setValidator(new QIntValidator(this)); QString XMAX=ui->lineEdit->text(); double xmax=XMAX.toDouble();
SamuelNLP
  • 4,038
  • 9
  • 59
  • 102
3
votes
1 answer

PyQt LineEdit with readline completer?

I've been working on a command line tool for which I'm now making a PyQT GUI. I'd like to take my current autocomplete implementation using the readline module, and put that in a QLineEdit text box. Is this possible? Do you have any…
Bradley Powers
  • 717
  • 7
  • 19
2
votes
1 answer

Invalid use of Ui

I'm a student programmer and I'm doing some GUI programing for my company and I have recently ran into an issue that I feel I need some assistance with. Im using Qt and some of its widgets are still confusing to me and the documentation is…
Wylie Coyote SG.
  • 1,009
  • 6
  • 22
  • 37
2
votes
1 answer

PyQt Collection of QLineEdit objects

Is there some way in PyQt to get a collection of all QLineEdit objects? I am trying to add a reset button that will blank out all text in all QLineEdit on a form, so I am looking for a way to loop through all QLineEdit objects rather than listing…
TimothyAWiseman
  • 14,385
  • 12
  • 40
  • 47
2
votes
2 answers

How to limit numbers accepted in a Lineedit

I’m trying to make a Lineedit that only accepts numbers from 1 to 12. But even using setValidator, the code can't limit the numbers. This is the function that has the LineEdit .(lineEdit should not accept numbers that are not between 1-12) using…