Home > Back-end >  C & QT mysql connection
C & QT mysql connection

Time:04-11

A variety of reasons the teacher gave me a program before others, and never learn c + +, the program run unable to connect to the database
 # include "datadig. H" 
# include "ui_datadig. H"
DataDig: : dataDig (QWidget * parent) :
QDialog (parent),
UI (new UI: : dataDig)
{
The UI - & gt; SetupUi (this);
SetWindowTitle (QStringLiteral (" launch configuration database "));
Settings=new QSettings (tr (" config. Ini "), QSettings: : IniFormat);
The UI - & gt; DataLin - & gt; SetText (Settings - & gt; The value (" PATH "). The toString ());
The UI - & gt; PassLin - & gt; SetText (Settings - & gt; The value (" PASSWORD "). The toString ());
The UI - & gt; PassLin - & gt; SetEchoMode (QLineEdit: : ");
The connect (UI - & gt; QuitBtn, SIGNAL (clicked (bool)), and this, SLOT (the close ()));
}
DataDig: : ~ dataDig ()
{
Delete the UI;
}
Void dataDig: : on_saveBtn_clicked ()
{
Settings - & gt; SetValue (tr (" PATH "), the UI - & gt; DataLin - & gt; The text ());
Settings - & gt; SetValue (tr (" PASSWORD "), the UI - & gt; PassLin - & gt; The text ());
}
Void dataDig: : on_pushButton_clicked ()
{
QString filename=QFileDialog: : getOpenFileName ();
if(! Filename. IsEmpty ()) {
The UI - & gt; DataLin - & gt; SetText (filename);
}
}

After the program is running, the menu can be set to start the database configuration, to enter the database path and password, input saved config. The ini file save fill path and the password, is it possible that is the path I choose, I tried to choose mysql. Exe, choose with navicat everywhere SQL file, all not line
  • Related