#include "MainWindow.h" #include "ui_MainWindow.h" #include #include #include #include #include MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_pattern(QRegularExpression(R"(^[A-Za-z]+\d+$)")) { ui->setupUi(this); setWindowTitle(QStringLiteral("Qt6 Legacy Migration Benchmark")); ui->label->setText(QStringLiteral("Bitte Text wie Test123 eingeben.")); ui->iconLabel->setPixmap(QPixmap(QStringLiteral(":/icons/app.png")).scaled(48, 48)); connect(ui->validateButton, &QPushButton::clicked, this, &MainWindow::onValidateClicked); connect(ui->screenButton, &QPushButton::clicked, this, &MainWindow::onScreenInfoClicked); } MainWindow::~MainWindow() { delete ui; } bool MainWindow::validateInput(const QString& text) const { return m_pattern.match(text).hasMatch(); } QString MainWindow::getScreenInfo() const { const QScreen* screen = QApplication::primaryScreen(); if (!screen) { return QStringLiteral("Screen: unavailable"); } const QRect geometry = screen->geometry(); return QStringLiteral("Screen: %1x%2").arg(geometry.width()).arg(geometry.height()); } void MainWindow::onValidateClicked() { const QString text = ui->lineEdit->text(); if (validateInput(text)) { ui->resultLabel->setText(QStringLiteral("Match")); } else { ui->resultLabel->setText(QStringLiteral("No match")); } } void MainWindow::onScreenInfoClicked() { const QString info = getScreenInfo(); ui->resultLabel->setText(info); }