title: How check fast, if database reachable? (Qt, QML, C++)- Linux
body: <p>I use qt with qml and c++. On my application i use a database. 
  It all works, if the database is reachable. </p>
  
  <p>My problem is, that i would like to check, if database is reachable (like ping). </p>
  
  <p>I tried </p>
  
  <pre><code>    db.setDatabaseName(dsn);
      if(db.isValid())
      {
  
          if(db.open())
          {
              //std::cout &lt;&lt;"Offene Datenbank";
              connected=true;
  
          }
          else
          {
              connected=false;
          }
  
  
      }
      else
      {
          connected=false;
      }
  </code></pre>
  
  <p>and give the connected value as result. But that takes very long (maybe 30 seconds), if there is no connection. How i can check fast, if i have a database connection? </p>
  
  <p>Is there maybe a way to break the command .open after 5 seconds not connected?</p>