int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlApplicationEngine engine; QQmlContext* context = engine.rootContext(); QString currPath = QDir::currentPath(); context->setContextProperty("currentPath", currPath); QScreen *screen = QApplication::screens().at(0); int width = screen->availableSize().width(); context->setContextProperty("availableWidth", width); int height = screen->availableSize().height(); context->setContextProperty("availableHeight", height); MainController* mainController = new MainController(); context->setContextProperty("mainController", mainController); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); }
LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::LoginDialog) { ui->setupUi(this); QScreen *screen = QApplication::screens().at(0); //int screenWidth = screen->availableSize().width(); int screenHeight = screen->availableSize().height(); QFont defaultHeight; defaultHeight.setPointSize(18); int ButtonHeight = screenHeight / 20; ui->label_User->setText("Benutzername:"); ui->label_User->setFont(defaultHeight); ui->label_password->setText("Passwort:"); ui->label_password->setFont(defaultHeight); ui->label_IP_login->setText("Server Url/IP:"); ui->label_IP_login->setFont(defaultHeight); ui->pushButton_OK->setText("OK"); ui->pushButton_OK->setMaximumHeight(ButtonHeight); ui->pushButton_cancel->setText("Abbrechen"); ui->pushButton_cancel->setMaximumHeight(ButtonHeight); ui->lineEdit_password->setEchoMode(QLineEdit::Password); ui->label_headline->setAlignment(Qt::AlignCenter); QFont font = ui->label_headline->font(); //Set layout of label font.setBold(true); font.setPointSize(screenHeight / 60); ui->label_headline->setFont(font); ui->label_headline->setText("HWWS Login"); QString IP = settingsIP.value("Url", "").toString(); ui->lineEdit_IP_login->setText(IP); QString User = settingsUser.value("name", "").toString(); ui->lineEdit_user->setText(User); QString Password = settingsUser.value("password", "").toString(); ui->lineEdit_password->setText(Password); }