I was wondering if anyone could direct me to an example of a login prompt that has a check box to "Remember Login Info." I would like to just write to a hidden file in the user's home directory if that kind of helps.
Here is what my main.cpp looks like that calls the login prompt, or maybe I should do it in the logindialog.cpp:
#include <QtGui/QApplication>
#include <QDesktopWidget>
#include <QSqlError>
#include <QMessageBox>
#include <QSqlDatabase>
#include "entryform.h"
#include "mainwindow.h"
#include "logindialog.h"
int main(int argc, char *argv[])
{
LoginDialog dlg;
dlg.setWindowTitle("Login");
if( dlg.
exec() == QDialog::Accepted ){ db.setHostName(dlg.loginDlgUi.serverLE->text());
db.setDatabaseName(dlg.loginDlgUi.databaseLE->text());
db.setUserName(dlg.loginDlgUi.usernameLE->text());
db.setPassword(dlg.loginDlgUi.passwordLE->text());
if ( db.open() ) {
MainWindow w;
r.
moveTopLeft(QApplication::desktop()->availableGeometry
().
topLeft());
w.setGeometry(r);
w.resize(800, 650);
w.show();
return a.exec();
}
} else {
QMessageBox::information(0,
"Login Canceled!",
"Login Canceled!");
return 1;
}
strRejected
= QString("The Login was rejected because: %1").
arg(db.
lastError().
text()).
toLatin1();
QMessageBox::information(0,
"Login Rejected!",strRejected
);
return 2;
};
#include <QtGui/QApplication>
#include <QDesktopWidget>
#include <QSqlError>
#include <QMessageBox>
#include <QSqlDatabase>
#include "entryform.h"
#include "mainwindow.h"
#include "logindialog.h"
int main(int argc, char *argv[])
{
QString strRejected = "";
QApplication a(argc, argv);
LoginDialog dlg;
dlg.setWindowTitle("Login");
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
if( dlg.exec() == QDialog::Accepted ){
db.setHostName(dlg.loginDlgUi.serverLE->text());
db.setDatabaseName(dlg.loginDlgUi.databaseLE->text());
db.setUserName(dlg.loginDlgUi.usernameLE->text());
db.setPassword(dlg.loginDlgUi.passwordLE->text());
if ( db.open() ) {
MainWindow w;
QRect r = w.geometry();
r.moveTopLeft(QApplication::desktop()->availableGeometry().topLeft());
w.setGeometry(r);
w.resize(800, 650);
w.show();
return a.exec();
}
} else {
QMessageBox::information(0,"Login Canceled!","Login Canceled!");
return 1;
}
strRejected = QString("The Login was rejected because: %1").arg(db.lastError().text()).toLatin1();
QMessageBox::information(0,"Login Rejected!",strRejected);
return 2;
};
To copy to clipboard, switch view to plain text mode
Thanks in advance
fnmblot
Bookmarks