Problem with enabling QPushButton!
Hello! Friends,
I am planning to design GUI wherein unless any user enters in QLineEdit a valid input it shouldn't enable one of the pushbuttons say Calculate. In the designer i have disabled the Calculate button. I have also set the inputMask in the designer to accept only 1-9 integers. I have disabled the button as soon as the calculate starts.
After which i used QLineEdit's "textChanged( const QString &)" property to enable the button and it worked properly, but it even enabled the button if "EmptyString" or anyother string which is inserted to LineEdit even if those are not displayed OR when Clear function is used which clears LineEdit's data.
Can anyone please suggest me which of the QLineEdit's property like ::isModified(), ::selectedText() or any other has to be used to solve my problem?
I will be obliged if helped.---->Thanks in Advance.
Re: Problem with enabling QPushButton!
What do you have in a slot connected to the textChanged signal?
Re: Problem with enabling QPushButton!
Hello! Wysota,
Thanks for replying. I have connected that siganl to a slot where i have: -
{ PushButton->setEnabled( TRUE ); }
So whenever i try to change the input to LineEdit may be its invalid input it enables the Calculate button. Even as Clear button clears LineEdit's data the textChanged signal is emitted which enables the button again. But i want to enable it only valid data is entered for which i have set the inputMask in the designer.
I have tried the same with functions like ::isModified(), ::selectedText() to check bool variable but its not working. Please help me.
Thanks again.
Re: Problem with enabling QPushButton!
Look at the textChanged() signal - it carries a parameter which contains the current text of the lineedit. You can check the text and if it is equal to the "password" of your choice, enable the button.
Re: Problem with enabling QPushButton!
Hello! Wysota,
Thanks again i used the textChanged() property & its working! But whever i use "Backspace" Key from the keyboard to cancel the selection it is not working properly.
I have used Clear button to clear() the LineEdit's text(), if user wishes to clear his selection. But whenever i use "Backspace" key to do the same, the text disappers but i dont think it clear's the text() property as clear() function does because the slot is not called in that case.
Can you please let me know where am i making mistake?--> Thanks in Advance.:)
Re: Problem with enabling QPushButton!
I have no idea what you are saying... Could you provide some code to demonstrate what you mean?
Re: Problem with enabling QPushButton!
Thank you Sir for helping me out, but i was able to solve it.
Best regards.