Results 1 to 6 of 6

Thread: PyQT QlineEdit signal problem

  1. #1
    Join Date
    May 2018
    Posts
    4
    Qt products
    Platforms
    Unix/X11 Windows

    Default PyQT QlineEdit signal problem

    Hi!
    Please, someone help me!

    I have a QLineEdit and I want to assign a Signal (textChanged()) to do something (to lock a Table Widget) when the lineEdit is no blank.

    i assigned the control textChanged() to a function which lock the table with: ui.tbPf.setEnabled(False) but when type some characters to this lineEdit, the table is not locked?

    What I do wrong? I have to use other Signal?


    Thank's a lot!

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: PyQT QlineEdit signal problem

    Reported the spam in #2.

    On the topic:
    - do you get any messages after you started your program the say something like "is no slot" or "is no signal"?
    - could you post some actual code?

    Ginsengelf

  3. #3
    Join Date
    May 2018
    Posts
    4
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: PyQT QlineEdit signal problem

    if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    MainWindow = QtGui.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)

    QtCore.QObject.connect(
    ui.txProces, QtCore.SIGNAL('keyPressEvent()'), lkTables)
    MainWindow.show()
    sys.exit(app.exec_())

    def lkTables():
    ui.tbPf.setEnabled(False)
    ui.tbEl.setEnabled(False)

    No errors, no nothing

  4. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: PyQT QlineEdit signal problem

    Quote Originally Posted by mist View Post
    QtCore.QObject.connect(ui.txProces, QtCore.SIGNAL('keyPressEvent()'), lkTables)
    I don't use PyQt, but this looks wrong to me: no receiver slot defined, and in C++ keyPressEvent is an event, not a signal, so it cannot be used like this.
    In C++ you would overload the keyPressEvent() method to add some custom stuff.

    Ginsengelf

  5. #5
    Join Date
    May 2018
    Posts
    4
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: PyQT QlineEdit signal problem

    Quote Originally Posted by Ginsengelf View Post
    I don't use PyQt, but this looks wrong to me: no receiver slot defined, and in C++ keyPressEvent is an event, not a signal, so it cannot be used like this.
    In C++ you would overload the keyPressEvent() method to add some custom stuff.

    Ginsengelf
    What is the easiest way to check if the text in a qlineedit is not blank?

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: PyQT QlineEdit signal problem

    QLineEdit::text() to get the text into a QString, QString::isEmpty() to check if it is blank. Connect your slot to the QLineEdit::editingFinished() signal to get notified when the user has stopped editing in the line edit.

    I am sure that there must be some PyQt examples that cover such basic operations as retrieving text from a line edit.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 9th June 2013, 04:16
  2. PyQt Signal and Slot Problem
    By HelderC in forum Newbie
    Replies: 0
    Last Post: 5th December 2011, 23:22
  3. Replies: 0
    Last Post: 27th October 2011, 11:23
  4. QLineEdit - lostFocus signal problem
    By Enygma in forum Qt Programming
    Replies: 6
    Last Post: 17th June 2010, 21:52
  5. Replies: 5
    Last Post: 6th September 2009, 17:32

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.