Exemple #1
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // Read DB settings from config.ini
    // !!! config file must be in the same directory as the executable program
    QSettings settings("config.ini", QSettings::IniFormat);
    QString strKey("DB.config/");
    QString strHost = settings.value( strKey + "host", "localhost").toString();
    QString strDatabase = settings.value( strKey + "database", "exlibris").toString();
    QString strUser = settings.value( strKey + "user").toString();
    QString strPassword = settings.value( strKey + "password").toString();

    // Connecting to DB
    if (!createConnection(strHost, strDatabase, strUser, strPassword))
        return 1;

    LoginForm login;
    login.show();

//    MainWindow w;
//    w.show();

    return a.exec();
}
Exemple #2
0
MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
    QRect screen = QApplication::desktop()->rect();
    setGeometry(screen);
    QImage image(QString(SHARE_DIR) + "/themes/light/simple_blue_widescreen.png");

    QPalette palette;
    palette.setBrush(this->backgroundRole(), QBrush(image.scaled(screen.width(), screen.right())));
    this->setPalette(palette);


    LoginForm *loginForm = new LoginForm(this);
    int offsetX = 2*screen.width()/5 - loginForm->width()/2;
    if (offsetX < 40)
    {
        offsetX = 40;
    }
    int offsetY = screen.height()/2 - loginForm->height()/2;
        loginForm->move(offsetX, offsetY);
    loginForm->show();
}