已经在Windows 10上安装了QT 6.5 ,怎样查看支持的数据库类型呢?
首先使用QT Creator 10.0.1 ,创建一个Widgets应用程序,如下图:

下一步 名称这里改为 HtQtSql
后续步骤中,类名(Class name),改为HtMainWindow
htmainwindow.h代码:
#ifndef HTMAINWINDOW_H
#define HTMAINWINDOW_H
#include <QMainWindow>
#include<QPushButton>
#include<QMessageBox>
#include <QSqlDatabase>
QT_BEGIN_NAMESPACE
namespace Ui { class HtMainWindow; }
QT_END_NAMESPACE
class HtMainWindow : public QMainWindow
{
Q_OBJECT
public:
HtMainWindow(QWidget *parent = nullptr);
~HtMainWindow();
private:
Ui::HtMainWindow *ui;
QPushButton* h_buttonHTTest=NULL;
private slots:
void on_h_buttonHTTest_clicked();
};
#endif // HTMAINWINDOW_H
htmainwindow.cpp代码:
#include "htmainwindow.h"
#include "ui_htmainwindow.h"
HtMainWindow::HtMainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::HtMainWindow)
{
ui->setupUi(this);
h_buttonHTTest=new QPushButton(this);
h_buttonHTTest->setText("HT Test");
h_buttonHTTest->move(50,50);
connect(h_buttonHTTest,SIGNAL(clicked()),this,SLOT(on_h_buttonHTTest_clicked()));
}
HtMainWindow::~HtMainWindow()
{
delete ui;
}
void HtMainWindow::on_h_buttonHTTest_clicked()
{
qDebug()<< QSqlDatabase::drivers();
QMessageBox::information(this,"Hovertree","请查看Qt Creator 应用程序输出");
}
在QC中运行的效果如下图:

可以看到,刚安装完的QT 6.5 ,支持的数据库类型为:
"QSQLITE", "QODBC", "QPSQL"
包括:
SQLite
PostgreSQL
另外也支持ODBC的数据库。
没有天然支持MySQL数据库。
本输出对应的语句:qDebug()<< QSqlDatabase::drivers();