Results 1 to 4 of 4

Thread: Validate Data in QDialog

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Validate Data in QDialog

    Here's an easy one...I'm running Qt 4.3 on Red Hat. My dialog contains a QTextEdit. When the user presses OK, I need to make sure that the data in the QTextEdit is valid. Since I used Qt Designer to make the dialog, it has a QDialogButtonBox. I have connected the "clicked" signal to a slot which checks the size of the QTextEdit. If the size is adequate, I call "accept()" otherwise the slot just returns. The problem is that the dialog disappears even when accept() is not called. If I use the reject() function, the dialog still disappears.

    Below is some code...thanks for any help or ideas.
    Joel

    Qt Code:
    1. DataSourceDlg :: DataSourceDlg()
    2. {
    3. connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(checkValues(QAbstractButton*)));
    4. }
    5.  
    6. void DataSourceDlg :: checkValues(QAbstractButton* button)
    7. {
    8.  
    9. if (button->text() == "Cancel")
    10. {
    11. accept(); // dismiss dialog with user click on Cancel
    12. } else {
    13. if (nodeLineEdit->text() > 3) {
    14. accept(); // dismiss dialog with valid data
    15. }
    16. }
    17. return; // invalid data do not dismiss dialog
    18. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 14th July 2007 at 00:09. Reason: missing [code] tags

Similar Threads

  1. QSqlQueryModel data update
    By psi in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2012, 04:59
  2. QByteArray with network data
    By merlvingian in forum Qt Programming
    Replies: 1
    Last Post: 1st June 2007, 18:53
  3. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 13:53
  4. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 17:17
  5. Replies: 16
    Last Post: 7th March 2006, 16: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
  •  
Qt is a trademark of The Qt Company.