Thank you for your help so far.
My SQL_BSP.pro now looks like this:
Qt Code:
  1. QT += core gui
  2. QT += sql
  3.  
  4. TARGET = SQL_BSP
  5. TEMPLATE = app
  6.  
  7. SOURCES += main.cpp\
  8. mainwindow.cpp
  9.  
  10. HEADERS += mainwindow.h
  11.  
  12. FORMS += mainwindow.ui
  13.  
  14. OTHER_FILES += \
  15. libpq.lib
To copy to clipboard, switch view to plain text mode 

I tried to get access to the sql db like this:
Qt Code:
  1. #include <QtSql>
  2. #include <QSqlError>
  3. #include <QSqlDriver>
  4. #include <QSqlDriverPlugin>
  5.  
  6. QSqlDatabase dbAlex = QSqlDatabase::addDatabase("QPSQL");
  7. dbAlex.setHostName("localhost");
  8. dbAlex.setPort(5433);
  9. dbAlex.setUserName("postgres");
  10. dbAlex.setPassword("***");
  11. dbAlex.setDatabaseName("QT");
  12. dbAlex.open("postgres", "***");
  13.  
  14. if (dbAlex.isOpen() == true)
  15. m_sConnState = "true";
  16. else
  17. m_sConnState = "false";
  18.  
  19. QSqlError dbError = dbAlex.lastError();
  20. m_sConnState = dbError.text();
  21. ui->lineEdit->setText(m_sConnState);
To copy to clipboard, switch view to plain text mode 

The message in my lineEdit now is "driver not loaded".

I now, I habe to work with QSqlDriver and QSqlDriverPlugin, but I have no idea how.