Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8527149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:28:28+00:00 2026-06-11T08:28:28+00:00

I am trying to show the loop data in Lineedit but it is not

  • 0

I am trying to show the loop data in Lineedit but it is not updating. Even the print command does not print the data on the terminal till I press any key other than return in lineedit. Have a look at the program and suggest me the changes:

import sys
import time
from PyQt4.QtGui import *
from PyQt4.QtCore import *

class MyFrame(QWidget):
def __init__(self):
    QWidget.__init__(self)

    self.le = QLineEdit(self)
    self.le.setGeometry(200,200,75,35)

    i=0
    self.le.setText(str(i))

    self.connect(self.le, SIGNAL("textChanged(QString)"),self.updatedvalue)

def updatedvalue(self):

    for i in range(1,5):
        self.le.setText(str(i))
        print(i)
        time.sleep(1)

app=QApplication(sys.argv)
f=MyFrame()
f.show()
app.exec_()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:28:29+00:00Added an answer on June 11, 2026 at 8:28 am

    You’ll need to call QApplication.instance.processEvents() after updating your QLineEdit‘s text to force an update, otherwise you won’t see anything until the final number.

    You also need to change your textChanged() signal to textEdited(). Using textChanged() your updatedvalue() function will be called again on the first pass of your loop once setText() is called because you’re updating the QLineEdit‘s text. The textEdited() signal won’t be triggered if you update the text programmatically.

    import sys
    import time
    from PyQt4.QtGui import *
    from PyQt4.QtCore import *
    
    class MyFrame(QWidget):
        def __init__(self):
            QWidget.__init__(self)
    
            self.le = QLineEdit(self)
            self.le.setGeometry(200,200,75,35)
    
            i = 0
            self.le.setText(str(i))
    
            self.connect(self.le, SIGNAL("textEdited(QString)"),self.updatedvalue)
    
        def updatedvalue(self):
            for i in range(1,5):
                self.le.setText(str(i))
                QApplication.instance().processEvents()
                print(i)
                time.sleep(1)
    
    app=QApplication(sys.argv)
    f=MyFrame()
    f.show()
    app.exec_()
    

    As Bob mentioned, using a QTimer would be much better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to get data from db, but in while loop, first data
I'm trying to use this for loop in order to show divs. But I
I am trying to loop though my users database to show each username in
I'm trying to create a basic for loop which creates an array but am
Using the wordpress loop and jquery, I'm trying to show/hide the content of the
Trying to show a label only when a certain item in a combo is
I'm trying to show/hide( or simply put - filter ) my markers( of houses
I'm trying to show a UIAlertView before actually deleting a cell from a UITableView
I'm trying to show a div when a user clicks in an input field,
I'm trying to show a list of links (in index.html) to text files in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.