#include "mainwindow.h"#include "ui_mainwindow.h"#include "QSqlDatabase"#include "QSql"#include "QSqlDriver"#include "QDebug"#include "QSqlError"QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", "mydb");MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ db.setDatabaseName("grafic"); db.setUserName("root"); db.setPassword(""); db.setHostName("localhost"); db.setConnectOptions(); if (!db.open()) qDebug()<<"Ups"<< QSqlDatabase::drivers(); else qDebug()<<"Ok"; ui->setupUi(this);}MainWindow::~MainWindow(){ delete ui;}