title: QT how to connect to SQLite database
body: <p>I am trying to connect to a database I created using DB BROWSER for SQLite have used this code to connect to my database. But it keeps giving errors while compiling. I tried following a YouTube tutorial as well and did as it said but got loads of errors.</p>
  <pre><code>QSqlDatabase db = QSqlDatabase::addDatabase(&quot;QSQLITE&quot;);
  db.setDatabaseName(&quot;:/accounts/login.db&quot;);
  db.open();
  </code></pre>
  <p>the errors I am getting:</p>
  <pre><code>agent.obj:-1: error: LNK2019: unresolved external symbol &quot;__declspec(dllimport) public: void __cdecl QSqlDatabase::setDatabaseName(class QString const &amp;)&quot; (__imp_?setDatabaseName@QSqlDatabase@@QEAAXAEBVQString@@@Z)
  &lt;br&gt;referenced in function&lt;br&gt;
  &quot;public: __cdecl agent::agent(class QWidget *)&quot; (??0agent@@QEAA@PEAVQWidget@@@Z)
  </code></pre>
  <pre><code>agent.obj:-1: error: LNK2019: unresolved external symbol &quot;_declspec(dllimport) public: static char const * const QSqlDatabase::defaultConnection&quot; (__imp?defaultConnection@QSqlDatabase@@2PEBDEB) 
  &lt;br&gt;referenced in function&lt;br&gt;
  &quot;public: __cdecl agent::agent(class QWidget *)&quot; (??0agent@@QEAA@PEAVQWidget@@@Z)
  </code></pre>
  <pre><code>agent.obj:-1: error: LNK2019: unresolved external symbol &quot;_declspec(dllimport) public: static class QSqlDatabase __cdecl QSqlDatabase::addDatabase(class QString const &amp;,class QString const &amp;)&quot; (__imp?addDatabase@QSqlDatabase@@SA?AV1@AEBVQString@@0@Z)
  &lt;br&gt;referenced in function&lt;br&gt;
  &quot;public: __cdecl agent::agent(class QWidget *)&quot; (??0agent@@QEAA@PEAVQWidget@@@Z) 
  </code></pre>
  <pre><code>agent.obj:-1: error: LNK2019: unresolved external symbol &quot;_declspec(dllimport) public: void __cdecl QSqlDatabase::setDatabaseName(class QString const &amp;)&quot; (__imp?setDatabaseName@QSqlDatabase@@QEAAXAEBVQString@@@Z)
  &lt;br&gt;referenced in function&lt;br&gt;
  &quot;public: __cdecl agent::agent(class QWidget *)&quot; (??0agent@@QEAA@PEAVQWidget@@@Z) 
  </code></pre>
  <pre><code>agent.obj:-1: error: LNK2019: unresolved external symbol &quot;__declspec(dllimport) public: static class QSqlDatabase __cdecl QSqlDatabase::addDatabase(class QString const &amp;,class QString const &amp;)&quot; (__imp_?addDatabase@QSqlDatabase@@SA?AV1@AEBVQString@@0@Z)
  &lt;br&gt;referenced in function&lt;br&gt;
  &quot;public: __cdecl agent::agent(class QWidget *)&quot; (??0agent@@QEAA@PEAVQWidget@@@Z)
  </code></pre>
  <pre><code>agent.obj:-1: error: LNK2019: unresolved external symbol &quot;__declspec(dllimport) public: static char const * const QSqlDatabase::defaultConnection&quot; (__imp_?defaultConnection@QSqlDatabase@@2PEBDEB)
  &lt;br&gt;referenced in function&lt;br&gt;
  &quot;public: __cdecl agent::agent(class QWidget *)&quot; (??0agent@@QEAA@PEAVQWidget@@@Z)
  </code></pre>