+ Reply to Thread
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
    Posts
    354
    Thanks
    9
    Thanked 43 Times in 41 Posts
    Qt products
    Qt4
    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
    Posts
    354
    Thanks
    9
    Thanked 43 Times in 41 Posts
    Qt products
    Qt4
    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
    3,650
    Thanks
    211
    Thanked 560 Times in 550 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    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.

+ Reply to Thread

Similar Threads

  1. Replies: 2
    Last Post: 9th June 2013, 03:16
  2. PyQt Signal and Slot Problem
    By HelderC in forum Newbie
    Replies: 0
    Last Post: 5th December 2011, 22:22
  3. Replies: 0
    Last Post: 27th October 2011, 10:23
  4. QLineEdit - lostFocus signal problem
    By Enygma in forum Qt Programming
    Replies: 6
    Last Post: 17th June 2010, 20:52
  5. Replies: 5
    Last Post: 6th September 2009, 16: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