Results 1 to 2 of 2

Thread: Can't get QLineEdit textEdited signal to work

  1. #1
    Join Date
    Sep 2011
    Posts
    21
    Qt products
    Platforms
    Unix/X11 Windows

    Default Can't get QLineEdit textEdited signal to work

    Using Python 2.7.2 and pyQT... This is the only forum I can get to from work. (Thank You NMCI!)

    I have a pop-up with 10 Buttons and a QLineEdit.

    I did not set any Masks or Validators when I constructed the GUI in QTDesigner.

    The "returnPressed" signal works.

    I can not get the "textEdited" signal to work at all, period.

    I come from a VB-6 background and the reference to (const QString&) in void textEdited (const QString&) has me completely "snowed".

    What I want to do is get the length of the entered text as it changes and update a characters-remaining count for the user.

    Of course if I can't get a signal emitted when each character is typed, I can't do that...

    Help!

    THANKS!

    Qt Code:
    1. class Oper_Comnt(QDialog, ui_OpComnt.Ui_OpComnt):
    2. """
    3. This Class creates an instance of the ui_OpComnt.Ui_OpComnt pop-up
    4. Dialog used for Displaying/Receiving Operator Comments.
    5. """
    6. def __init__(self, text, NumChars=255, parent=None):
    7. super(Oper_Comnt, self).__init__(parent)
    8. self.__index = 0
    9. self.setupUi(self)
    10. self.setModal(True)
    11. self.NumChars = NumChars
    12.  
    13. # Set up events for Button Clicks
    14. Selection=[]
    15. for i in range(10):
    16. Selection.append(getattr(self, "Comment_%d" %(i+1)) )
    17. self.connect(Selection[i],SIGNAL("clicked()"),
    18. self.comment_click)
    19.  
    20. self.connect(self.lineEdit,SIGNAL("returnPressed()"),self.usr_enter)
    21.  
    22. self.connect(self.lineEdit,SIGNAL("textEdited()"),self.new_char)
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can't get QLineEdit textEdited signal to work

    In a C++ environment running your code would emit a warning about the connect() call telling you that the signal does not exist: I do not know if PyQt does similar.

    The QLineEdit::textEdited() passes a QString value to any connected slot: the new text in the line edit. The signal signature would be
    Qt Code:
    1. SIGNAL("textEdited(QString)")
    To copy to clipboard, switch view to plain text mode 
    and the receiving slot needs to handle the string parameter.

Similar Threads

  1. clicked() signal for QLineEdit
    By smarinr in forum Qt Programming
    Replies: 10
    Last Post: 26th June 2019, 16:35
  2. selectAll in QLineEdit does not work
    By Ishmael in forum Newbie
    Replies: 4
    Last Post: 25th May 2015, 05:26
  3. QLineEdit: textEdited called on backspace
    By akiross in forum Qt Programming
    Replies: 2
    Last Post: 14th August 2011, 22:47
  4. Replies: 0
    Last Post: 31st May 2011, 11:46
  5. textChanged vs textEdited
    By Raccoon29 in forum Newbie
    Replies: 4
    Last Post: 27th March 2008, 17:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.