I have a Connect button in mainwindow.ui
void MainWindow::on_pushButton_clicked()
{
ConectarDB = QSqlDatabase::addDatabase("QMYSQL");
ConectarDB.setHostName("localhost");
ConectarDB.setDatabaseName("Banco");
ConectarDB.setPort(3306);
ConectarDB.setUserName("root");
ConectarDB.setPassword("root");}
It works perfectly, but I have two doubts:
1) How would I make a message appear confirming that the connection was successful, if the button was clicked?
2) Once connected, I have another form with a comboBox in it.
Buscar_por_CURSO::Buscar_por_CURSO(QWidget *parent) :
QDialog(parent),
ui(new Ui::Buscar_por_CURSO)
{
ui->setupUi(this);
mBuscaCurso = new QSqlTableModel(this);
mBuscaCurso->setTable("Cursos");
mBuscaCurso->select();
ui->comboBox->setModel(mBuscaCurso);
}
My table Courses:
Create table Cursos(
ID_curso int not null auto_increment,
Nome_curso varchar (50),
primary key (ID_curso)
)default charset = utf8;
This is what the comboBox looks like in the TrackID , but I would like it to be the TrackName .
How do I resolve this?
Thank you in advance