Adds qt migration example
This commit is contained in:
1 parent
e8488dd40e
commit
044885dddb
19 files changed
+1294
-2
No files matched your search
@@ -0,0 +1,53 @@
|
||||
#include "MainWindow.h"
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QTextCodec>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
#include <QRect>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
, legacyPattern("^[A-Za-z]+\\d+$")
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
QString title = codec->toUnicode("Qt5 Legacy Migration Benchmark");
|
||||
setWindowTitle(title);
|
||||
|
||||
ui->label->setText(codec->toUnicode("Bitte Text wie Test123 eingeben."));
|
||||
ui->iconLabel->setPixmap(QPixmap(":/icons/app.png").scaled(48, 48));
|
||||
|
||||
connect(ui->validateButton, SIGNAL(clicked()), this, SLOT(onValidateClicked()));
|
||||
connect(ui->screenButton, SIGNAL(clicked()), this, SLOT(onScreenInfoClicked()));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::onValidateClicked()
|
||||
{
|
||||
QString text = ui->lineEdit->text();
|
||||
|
||||
if (legacyPattern.exactMatch(text)) {
|
||||
ui->resultLabel->setText("Match");
|
||||
} else {
|
||||
ui->resultLabel->setText("No match");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onScreenInfoClicked()
|
||||
{
|
||||
QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
||||
QString info = QString("Screen: %1x%2")
|
||||
.arg(screenGeometry.width())
|
||||
.arg(screenGeometry.height());
|
||||
|
||||
ui->resultLabel->setText(info);
|
||||
}
|
||||
Reference in new issue
Block a user