Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Throw is not supported in event handler :(
Forum Updated to NodeBB v4.3 + New Features

Throw is not supported in event handler :(

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mmallad
    wrote on last edited by
    #1

    I had used exceptional handling in event handler. When exceptions occurs the program gets crashed with message qt does not support throw in event handler. so is there any way to manage this with using throw statement.
    @void Application::Validate()
    {
    //Do validation here.
    try
    {
    if(!QRegExp("[a-zA-Z]{2,}").exactMatch(this->fname))
    {
    throw FNAME;
    }
    else if(!this->mname.isEmpty() && !QRegExp("[a-zA-Z]{2,}").exactMatch(this->fname))
    {
    throw MNAME;
    }
    else if(!QRegExp("[a-zA-Z]{2,}").exactMatch(this->lname))
    {
    throw LNAME;
    }
    else if(!QRegExp("[a-zA-Z0-9]{2,}").exactMatch(this->passportNo))
    {
    throw PASSPORTNO;
    }
    else if(!QRegExp("[a-zA-Z]{2,}").exactMatch(this->nationality))
    {
    throw NATIONALITY;
    }
    else if(!QRegExp("^[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}$").exactMatch(this->dateOfIssue))
    {
    throw DATEOFISSUE;
    }
    else if(!QRegExp("^[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}$").exactMatch(this->dateOfExpire))
    {
    throw DATEOFEXPIRE;
    }
    else if(!QRegExp("^[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}$").exactMatch(this->dateOfBirth))
    {
    throw DATEOFBIRTH;
    }
    else if(!QRegExp("[a-zA-Z]{2,}").exactMatch(this->placeOfIssue))
    {
    throw PLACEOFISSUE;
    }
    else if(!QRegExp("[a-zA-Z\s]{2,}").exactMatch(this->fatherName))
    {
    throw FATHERNAME;
    }
    else if(!QRegExp("[a-zA-Z\s]{2,}").exactMatch(this->motherName))
    {
    throw MOTHERNAME;
    }

    }
    catch(QString ex)
    {
        throw ex;
    }
    

    }@

    this Validate method is called from the event handler.

    Dpak Malla

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Have a look at "Exception Safety":http://qt-project.org/doc/qt-4.8/exceptionsafety.html

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved