PyQt5 QLineEditor help!!!
On 1/29/20 6:11 PM, Souvik Dutta wrote:
> Hi guys I just started to learn PyQt5 and was wondering if like kivy we can
> delete the text in a textbox after taking the input. That is I want to make
> the textbox blank after the text is read. Also can you suggest a way to
> connect a cancel button with a function so that when the cancel button is
> clicked it exists a window. Tank you in advance.
How do you know when the input is done (taken)? If it's from pressing
Enter, then you'll probably have to capture that keystroke somehow (is
there a signal defined in QWidget that might do that?). If it's from a
button press that activates something, then from the button click
callback handler you would call clear() on the QLineEditor instance.
You can definitely close a window on a cancel button click. If you just
want to hide the window for displaying in the future, call
setVisible(false) on the window object. If you want to destroy the
window object, you would probably call the "destroy()" method of the
window, and then delete the python reference to it (either let it go out
of scope, or use del on it).