qt-migration-copilot-demo/pipeline/head There was a failure building this commit
Entire-Checkpoint: c1ee98dc34a3
55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
#include "MainWindow.h"
|
|
|
|
#include "ui_MainWindow.h"
|
|
|
|
#include <QApplication>
|
|
#include <QPixmap>
|
|
#include <QScreen>
|
|
#include <QString>
|
|
|
|
MainWindow::MainWindow(QWidget* parent)
|
|
: QMainWindow(parent), ui(new Ui::MainWindow), pattern(QRegularExpression(R"(^[A-Za-z]+\d+$)"))
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
// Qt6 uses UTF-8 by default; no codec needed
|
|
setWindowTitle(QString::fromUtf8("Qt6 Migrated Benchmark"));
|
|
ui->label->setText(QString::fromUtf8("Bitte Text wie Test123 eingeben."));
|
|
ui->iconLabel->setPixmap(QPixmap(":/icons/app.png").scaled(48, 48));
|
|
|
|
// Modern function-pointer connect syntax
|
|
connect(ui->validateButton, &QPushButton::clicked, this, &MainWindow::onValidateClicked);
|
|
connect(ui->screenButton, &QPushButton::clicked, this, &MainWindow::onScreenInfoClicked);
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void MainWindow::onValidateClicked()
|
|
{
|
|
const QString text = ui->lineEdit->text();
|
|
|
|
if (pattern.match(text).hasMatch())
|
|
{
|
|
ui->resultLabel->setText(QString::fromUtf8("Match"));
|
|
}
|
|
else
|
|
{
|
|
ui->resultLabel->setText(QString::fromUtf8("No match"));
|
|
}
|
|
}
|
|
|
|
void MainWindow::onScreenInfoClicked()
|
|
{
|
|
// Qt6: Use QScreen instead of deprecated QDesktopWidget
|
|
const QScreen* screen = QApplication::primaryScreen();
|
|
if (screen)
|
|
{
|
|
const QRect screenGeometry = screen->geometry();
|
|
const QString info =
|
|
QString::fromUtf8("Screen: %1x%2").arg(screenGeometry.width()).arg(screenGeometry.height());
|
|
ui->resultLabel->setText(info);
|
|
}
|
|
} |