Results 1 to 5 of 5

Thread: Checking that value of ui elements has been changed.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2013
    Posts
    40
    Thanks
    6
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Post Checking that value of ui elements has been changed.

    Hi All,

    Is there any way to check that the ui elements(line edit,combo box,etc.) of the dialog has been changed.
    What I want is to show a message to the user if he changes the value of any single ui element, saying that details have been partially filled.
    What i can do is use connect for each ui element & based on the value changed of each element i am setting a boolean flag & at the time of close event i am checking that boolean flag.
    But Its quite complicate to check it for each widget.
    Is there any easier way.
    Code that I am using for single ui element is,
    Qt Code:
    1. connect(ui->leAge,SIGNAL(textChanged(QString)),this,SLOT(functChanged())); //In Constructor
    2.  
    3. void DemoDialog::functChanged() //Will be called if value of line edit (ui->leAge) is changed
    4. {
    5. flag=true;
    6. }
    7.  
    8. void DemoDialog::closeEvent(QCloseEvent *event)
    9. {
    10. if (flag) {
    11. if (QMessageBox::warning(this,"Close","Do you want to close?",QMessageBox::Yes|QMessageBox::No)==QMessageBox::Yes) {
    12. this->close();
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    Thanks in advnc.

    Regards,
    Rohit

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Checking that value of ui elements has been changed.

    Hmm. If you have a method that reads all input elements, then you could call that at the beginning, store all value locally, and then compare with the data at the end.

    Cheers,
    _

Similar Threads

  1. Checking QByteArray for certain values
    By -Kyr0s- in forum Qt Programming
    Replies: 19
    Last Post: 14th November 2011, 11:47
  2. Checking QByteArray
    By camol in forum Qt Programming
    Replies: 3
    Last Post: 18th March 2011, 14:07
  3. Checking for gui events
    By mgb in forum Qt Programming
    Replies: 8
    Last Post: 8th February 2011, 23:07
  4. Checking if bad pointer?
    By steg90 in forum Qt Programming
    Replies: 4
    Last Post: 22nd May 2007, 10:06
  5. checking for null
    By drkbkr in forum General Programming
    Replies: 6
    Last Post: 13th March 2006, 22:54

Tags for this Thread

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.