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

Calculate max length of QLineEdit to suit its width

I created some QLineEdit, which have different sizes. I want to set the max length of those to suit the width of them. To be more specific: for example, with a width of 50, I will only allow to enter about 7 characters, because the size of each…
user2652023
  • 197
  • 2
  • 16
2
votes
2 answers

Why is returnPressed called before editingFinished? Can I reorder it?

I use the editingFinished signal to validate/correct/cache some value. When a button is pressed, I then expect the value in the field to be correct. Now to make my work faster, I connect returnPressed to call what the button press would have called.…
Shahbaz
  • 46,337
  • 19
  • 116
  • 182
2
votes
1 answer

QLineEdit not updating text with QKeyEvent

I'm trying to implement a virtual keyboard widget. The simplest way I could think of is to create QKeyEvent instances and send them with QApplication.postEvent() to the widget in focus. First, I'm trying to update a fixed QLineEdit that I have, so…
Daniel Severo
  • 1,768
  • 2
  • 15
  • 22
2
votes
0 answers

Completion for a QLineEdit with multiple models/categories

I'd like to build a completion for a QLineEdit which can take several completion models and organizes them as categories. I have a working solution based on a QSortFilterProxyModel and a tree model for the items: The root items in the model show up…
2
votes
2 answers

Get plain text from QLineEdit

I want to retrieve plain text from QLineEdit() object. The text method returns a QString object. I just want a simple string object. I am using pyqt4. def n(self): new_label=QLineEdit() new_label.setText("txt") txt=self.new_label.text() …
laryhaks
  • 37
  • 1
  • 6
2
votes
3 answers

QLineEdit IP partial validation

In my project I want to filter some of my data via IP input. I also want to allow to filter by partial IP input for example : 192.168. I found out how to set the complete IP validation. QString oIpRange; QRegExpValidator *poIpValidator; …
Simon
  • 1,522
  • 2
  • 12
  • 24
2
votes
2 answers

How to show QMenu on left click

The QMenu shows up on a QLineEdit right-click. Question: How to modify this code to show the menu on a left-click as well? from PyQt4.QtCore import * from PyQt4.QtGui import * import sys class MyWindow(QWidget): def __init__(self, *args): …
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
2
votes
3 answers

How can I assign lineEdits to some variable?

I am new to working with Qt. And I got stuck at this thing. I have a lot of lineEdits in my application, And the values in it may change any time while the application is running. Values in lineEdits would be only integers. At some stage I need to…
vinayawsm
  • 845
  • 9
  • 28
2
votes
1 answer

PyQt: Set text in a QLabel adding letter by letter

I'm trying to create an application that displays the contents of a QLabel (or a QTextEdit) by adding the letters one by one (as if the application were writing them). This is an example in python: import os, time def write(text, time): base =…
u34na
  • 33
  • 1
  • 3
2
votes
2 answers

QDoubleValidator accepts multiple decimal points

I'm using a QDoubleValidator for my QLineEdit. The application locale (set in QtCreator) is QLocale::German. Now when I enter a valid double (either using a dot or a comma as decimal separator) writing to the textedit as well as converting the…
Uroc327
  • 1,379
  • 2
  • 10
  • 28
2
votes
3 answers

Add a click on QLineEdit

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,…
EricBkc
  • 369
  • 2
  • 4
  • 12
2
votes
2 answers

Python Qt QLineEdit weird encoding

I have a situation that has me puzzled. I have a QLineEdit in my interface so when I populate it with the following text ' (it's aramaic) and I have the correct fonts installed on my machine so I can see the fonts in browsers and all but these…
vallllll
  • 2,731
  • 6
  • 43
  • 77
2
votes
3 answers

QLineEdit to accept only one character/digit

I want to have a QLineEdit that accepts only a character or digit . Is there a possibility to set it like in html an input to have a maxlength ? I mean to do this from the constructor of QLineEdit ? I don't need something complicated ...
user3009269
  • 442
  • 6
  • 14
2
votes
1 answer

Get text prior to edit from inside QLineEdit::textEdited()

When I receive a QLineEdit::textEdited() signal, can I see what the text was prior to the edit? I need to compare the text as it was prior to the edit and the text after the edit. The textEdited() signal has only one argument, which is the new text.…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
2
votes
1 answer

How to set focus on a widget at app startup?

I'm trying to set the focus on QLineEdit widget at app startup but for some reasons it fails. Calling the method which includes the QLineEdit_object.setFocus() and is bound to a button click, works perfectly. However on startup, it seems like it…
hmnhmn
  • 173
  • 2
  • 9