Greetings all, I hope you're doing well.

I have found myself in a bit of a gap semester due to COVID, and I decided to brush up on my programming and learn Qt. I decided to build a toy application from start to finish that communicates with a PostgreSQL Database. I really like the signal/slot systems and the Core/GUI libraries, they're very useful. However, as soon as I tried to connect with my database, I ran into problems. First of all, my system is:
  • Windows 10, 64-bit
  • Qt 5.15.1
  • PostgreSQL 13, 64-bit
  • MinGW 8.1 64-bit
  • MSVC 2019 64-bit

The error, as you may have guessed, is the following:

Qt Code:
  1. QSqlDatabase: QPSQL driver not loaded
  2. QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
To copy to clipboard, switch view to plain text mode 

After a bit of stumbling around in Google, I figured I needed to download the Qt source code and compile the driver (plugin) myself. I downloaded the source, navigated to the appropriate folder (I also copied the mingw qsqlpsql.dll files to that directory) and ran the following command:

Qt Code:
  1. C:\Qt\5.15.1\mingw81_64\bin\qmake.exe -- PSQL_INCDIR="C:/Program Files/PostgreSQL/13/include" PSQL_LIBDIR="C:/Program Files/PostgreSQL/13/lib" -sql-psql
To copy to clipboard, switch view to plain text mode 

This produced the following:

Qt Code:
  1. Running configuration tests...
  2. Done running configuration tests.
  3.  
  4. Configure summary:
  5.  
  6. Qt Sql Drivers:
  7. DB2 (IBM) .............................. no
  8. InterBase .............................. no
  9. MySql .................................. no
  10. OCI (Oracle) ........................... no
  11. ODBC ................................... no
  12. PostgreSQL ............................. no
  13. SQLite2 ................................ no
  14. SQLite ................................. yes
  15. Using system provided SQLite ......... no
  16. TDS (Sybase) ........................... no
  17.  
  18. ERROR: Feature 'sql-psql' was enabled, but the pre-condition 'libs.psql' failed.
  19.  
  20. Check config.log for details.
To copy to clipboard, switch view to plain text mode 

As you can see, it cannot see the PostgreSQL driver. After checking config.log I found out that it's actually trying to use a 32-bit mingw, and it can't find most of the things it's looking for.

Honestly, I am quite lost at this point. There are many many people online with pretty much the same problem as me but I've tried all google results to no avail. Note that I've also (a) reinstalled Qt and PostgreSQL at least twice so far, (b) Tried to use MSVC instead of MinGW without success and (c) tried to copy all the dlls and libs in the sqldrivers folder.

I am unsure what to do next and I feel I've probably made a complete mess. Does anybody have any idea what I should do? Part of me feels like this shouldn't be that difficult and I am missing something fundamental. I very much appreciate and welcome any input or advice. Thank you.