Results 1 to 7 of 7

Thread: Problem with enabling QPushButton!

  1. #1
    Join Date
    Feb 2008
    Posts
    74
    Thanks
    31
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy 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.
    Last edited by Krish; 4th March 2008 at 16:29.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with enabling QPushButton!

    What do you have in a slot connected to the textChanged signal?

  3. #3
    Join Date
    Feb 2008
    Posts
    74
    Thanks
    31
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

  5. The following user says thank you to wysota for this useful post:

    Krish (5th March 2008)

  6. #5
    Join Date
    Feb 2008
    Posts
    74
    Thanks
    31
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question 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.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with enabling QPushButton!

    I have no idea what you are saying... Could you provide some code to demonstrate what you mean?

  8. #7
    Join Date
    Feb 2008
    Posts
    74
    Thanks
    31
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: Problem with enabling QPushButton!

    Thank you Sir for helping me out, but i was able to solve it.

    Best regards.
    Last edited by Krish; 5th March 2008 at 14:57.

Similar Threads

  1. QPixmap in QPushButton size problem
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 22nd January 2008, 12:50
  2. QPushButton problem
    By sincnarf in forum Qt Programming
    Replies: 4
    Last Post: 20th August 2007, 21:02
  3. QPushbutton problem
    By amulya in forum Qt Programming
    Replies: 5
    Last Post: 30th August 2006, 08:11
  4. Replies: 16
    Last Post: 7th March 2006, 15:57

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.