Results 1 to 3 of 3

Thread: Change property of QInputDialog button

  1. #1
    Join Date
    Apr 2012
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Change property of QInputDialog button

    Hi, I have this problem. I have application where I use QInputDialog for passwords. What I want is to disable Ok button until user inputs at least 4 numbers into dialog. Is there some way to do it? I can retrieve length of input by reacting on signal textValueChanged(QString), but how to change property of QInputDialog button? Is it even possible?

  2. #2
    Join Date
    Sep 2011
    Posts
    26
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Change property of QInputDialog button

    Quote Originally Posted by Raadush View Post
    Hi, I have this problem. I have application where I use QInputDialog for passwords. What I want is to disable Ok button until user inputs at least 4 numbers into dialog. Is there some way to do it? I can retrieve length of input by reacting on signal textValueChanged(QString), but how to change property of QInputDialog button? Is it even possible?

    i think you cant enable/disable the standard buttons from qinputdialog.
    Why you doesn't make a QWidget with QLineEdit field and implent your own qpushbutton? then you can check the length of the qlineedit and enable/disable the qpushbutton.

    i think that is the better way to handle this.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Change property of QInputDialog button

    Well, you can access the buttons:
    Qt Code:
    1. d.show();
    2. QList<QDialogButtonBox*> l = d.findChildren<QDialogButtonBox*>();
    3. if (!l.isEmpty())
    4. l.first()->button(QDialogButtonBox::Ok)->setEnabled(false);
    To copy to clipboard, switch view to plain text mode 
    but you shouldn't. Better code your own dialog.

Similar Threads

  1. Replies: 1
    Last Post: 20th February 2012, 21:44
  2. Replies: 1
    Last Post: 18th November 2010, 08:39
  3. Change Stylesheet Using Dynamic Property
    By stefanadelbert in forum Qt Programming
    Replies: 4
    Last Post: 26th August 2010, 08:48
  4. Replies: 6
    Last Post: 21st August 2010, 22:09
  5. How to mark Property name in Q_PROPERTY for language change??
    By Ankitha Varsha in forum Qt Programming
    Replies: 7
    Last Post: 14th April 2010, 14:22

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.