1 Star 1 Fork 1

lzh280/Qt_painter

forked from rbc/Qt_painter 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
painter.cpp 1.69 KB
一键复制 编辑 原始数据 按行查看 历史
lc_look 提交于 2022-12-05 22:06 . Qt 机械设计杆件杆的初始化
//主函数执行区间
#include "painter.h"
#include "ui_painter.h"
#include <QGraphicsItem>
#include <QPainter>
#include <QGraphicsLineItem>
#include <QGraphicsScene>
#include "gan.h"
#include <QTimer>
//整体变量区间
QTimer *tim = new QTimer();
painter::painter(QWidget *parent)//init space
: QDialog(parent)
, ui(new Ui::painter)
{
ui->setupUi(this);
ui->OutputText->setReadOnly(true);
ui->OutputText->append("**欢迎使用本程序**");
connect(tim,SIGNAL(timeout()),this,SLOT(onTimeOut()));
//开始创建整体计时器
//变量初始化
this->LengthGan1 = ui->GanLength1;
this->LengthGan2 = ui->GanLength2;
this->LengthGan3 = ui->GanLength3;
this->LengthGan4 = ui->GanLength4;
}
painter::~painter()
{
delete ui;
}
void painter::on_pushButton_clicked()
{
Gan*gan = new Gan(ui->GanLength1->value(),ui->GanLength2->value(),ui->GanLength3->value(),ui->GanLength4->value(),ui);
gan->Check();
if(!(gan->isInputLeagal))
{
ui->OutputText->append("程序无法继续执行");
return;
}
double TimeCount = ui->Times->value();//显示每秒钟运行的次数默认为10次
tim->setInterval(int(1000/TimeCount));//用1秒钟除以执行次数
tim->start();//开始执行定时器
ui->OutputText->append("Timer start to run");
}
void painter::on_stop_clicked()
{
}
void painter::onTimeOut()
{
QGraphicsScene *Scence = new QGraphicsScene();
QGraphicsLineItem *Line_1 = new QGraphicsLineItem();
Line_1->setLine(QLineF(1.2,23,22.2,4.2));
QPen *pen = new QPen();
pen->setColor(Qt::red);
pen->setWidth(10);
Line_1->setPen(*pen);
Scence->addItem(Line_1);
ui->graphicsView->setScene(Scence);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lzh280/qt_painter.git
git@gitee.com:lzh280/qt_painter.git
lzh280
qt_painter
Qt_painter
master

搜索帮助