纸带
This commit is contained in:
parent
89f87dcad1
commit
a956c1e10e
@ -10,10 +10,12 @@ CONFIG += c++11
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp
|
mainwindow.cpp \
|
||||||
|
mylabel.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
mainwindow.h
|
mainwindow.h \
|
||||||
|
mylabel.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 6.0.0, 2021-12-16T00:03:13. -->
|
<!-- Written by QtCreator 6.0.0, 2021-12-16T13:42:03. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|||||||
1
main.cpp
1
main.cpp
@ -1,6 +1,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|||||||
@ -113,6 +113,14 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
btn_step->setGeometry(930, 390, 50, 40);
|
btn_step->setGeometry(930, 390, 50, 40);
|
||||||
btn_step->setText("下一步");
|
btn_step->setText("下一步");
|
||||||
|
|
||||||
|
//纸带
|
||||||
|
for(int i=0;i<24;i++)
|
||||||
|
{
|
||||||
|
label[i]=new MyLabel(this);
|
||||||
|
label[i]->setPos(30+40*i,500);
|
||||||
|
label[i]->hide();
|
||||||
|
}
|
||||||
|
|
||||||
QObject::connect(btn_import, SIGNAL(clicked()), this, SLOT(importFile()));
|
QObject::connect(btn_import, SIGNAL(clicked()), this, SLOT(importFile()));
|
||||||
QObject::connect(btn_confirm, SIGNAL(clicked()), this, SLOT(startSimulate()));
|
QObject::connect(btn_confirm, SIGNAL(clicked()), this, SLOT(startSimulate()));
|
||||||
QObject::connect(btn_step, SIGNAL(clicked()), this, SLOT(nextStep()));
|
QObject::connect(btn_step, SIGNAL(clicked()), this, SLOT(nextStep()));
|
||||||
@ -177,6 +185,15 @@ void MainWindow::importFile()
|
|||||||
void MainWindow::startSimulate()
|
void MainWindow::startSimulate()
|
||||||
{
|
{
|
||||||
QString str=line_str->text();
|
QString str=line_str->text();
|
||||||
|
label[2]->setText("B");
|
||||||
|
label[2]->show();
|
||||||
|
for(int i=0;i<str.length();i++)
|
||||||
|
{
|
||||||
|
label[i+3]->setText(str[i]);
|
||||||
|
label[i+3]->show();
|
||||||
|
label[i+4]->setText("B");
|
||||||
|
label[i+4]->show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::nextStep()
|
void MainWindow::nextStep()
|
||||||
|
|||||||
@ -16,6 +16,9 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include "mylabel.h"
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
@ -47,5 +50,6 @@ private:
|
|||||||
QListWidget *list_file,*list_func;
|
QListWidget *list_file,*list_func;
|
||||||
QPushButton *btn_import,*btn_confirm,*btn_step;
|
QPushButton *btn_import,*btn_confirm,*btn_step;
|
||||||
|
|
||||||
|
MyLabel* label[25];
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
48
mylabel.cpp
Normal file
48
mylabel.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include "mylabel.h"
|
||||||
|
|
||||||
|
MyLabel::MyLabel(QMainWindow *parent)
|
||||||
|
{
|
||||||
|
label=new QLabel(parent);
|
||||||
|
QFont font ("Microsoft YaHei",20,75);
|
||||||
|
label->setFont(font);
|
||||||
|
label->setFixedSize(40,55);
|
||||||
|
label->setAlignment(Qt::AlignCenter);
|
||||||
|
label->setStyleSheet("border-width: 2px;border-style: solid;border-color: rgb(236, 170, 201);background-color: rgb(255, 20, 20);");
|
||||||
|
}
|
||||||
|
|
||||||
|
MyLabel::MyLabel(QMainWindow *parent,QString text)
|
||||||
|
{
|
||||||
|
label=new QLabel(parent);
|
||||||
|
label->setText(text);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MyLabel::~MyLabel()
|
||||||
|
{
|
||||||
|
delete label;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyLabel::setGeometry(int ax,int ay,int aw,int ah)
|
||||||
|
{
|
||||||
|
label->setGeometry(ax,ay,aw,ah);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyLabel::setText(QString text)
|
||||||
|
{
|
||||||
|
label->setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyLabel::hide()
|
||||||
|
{
|
||||||
|
label->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyLabel::show()
|
||||||
|
{
|
||||||
|
label->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyLabel::setPos(int x,int y)
|
||||||
|
{
|
||||||
|
label->setGeometry(x,y,40,55);
|
||||||
|
}
|
||||||
27
mylabel.h
Normal file
27
mylabel.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef MYLABEL_H
|
||||||
|
#define MYLABEL_H
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QString>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QFrame>
|
||||||
|
|
||||||
|
class MyLabel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyLabel(QMainWindow *parent);
|
||||||
|
MyLabel(QMainWindow *parent,QString text);
|
||||||
|
~MyLabel();
|
||||||
|
void setText(QString text);
|
||||||
|
void setGeometry(int ax,int ay,int aw,int ah);
|
||||||
|
void hide();
|
||||||
|
void show();
|
||||||
|
void setPos(int x,int y);
|
||||||
|
private:
|
||||||
|
QLabel *label;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MYLABEL_H
|
||||||
Loading…
Reference in New Issue
Block a user