资源简介
在Qtopia-2.2.0环境下,实现读取txt数据并根据数据绘制曲线
代码片段和文件信息
#include “curves.h“
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define length 640//length取屏幕大小
void showAfter();
void showbefore();
int number=0;
int Ylarge=20;
int xwidth=20;
int yposition=400;
int WIDTH;
float trydata[1500];
void readFlightCurves(float *trydata)
{
QStringList lines;
QFile file(“/opt/embedSky/Qte/x86-qtopia-2.2.0/pro/readt/test2.txt“);
if(file.open(IO_ReadOnly))
{
QTextStream in(&file);
QString line;
int n=0;
//while(!in.atEnd())
while(n!=1500) {
line=in.readLine();
trydata[n]=line.toFloat();
// printf(“%f\n“trydata[n]);
//printf(“%s\n“line.latin1());
lines +=line;
n++;
}
}
file.close();
}
void Curves::paintEvent(QPaintEvent *event)
{
//if(PushButton1)
//connect (PushButton1 SIGNAL(clicked()) this SLOT(drawcurves()));
}
void Curves::drawxy()
{
int i=0;
/*label1=new Qlabel(“0“);
label->setMaximumHeight(yposition);
label->setMaximumWidth(xwidth);
label1=new Qlabel(“5“);
label->setMaximumHeight();
label->setMaximumWidth();
label1=new Qlabel(“10“);
label->setMaximumHeight();
label->setMaximumWidth();
label1=new Qlabel(“15“);
label->setMaximumHeight();
label->setMaximumWidth();
label1=new Qlabel(“20“);
label->setMaximumHeight();
label->setMaximumWidth();*/
QPainter painter(this);
QPen pen(black2Qt::SolidLine);
painter.setPen(pen);
painter.moveTo(xwidthyposition);
//画坐标轴
painter.drawLine(xwidthypositionxwidth0);//y轴显示
for(i=0;i<5;i++)
{
painter.drawLine(xwidthyposition-5*i*Ylarge1000yposition-5*i*Ylarge);//y轴显示
}
}
void Curves::drawcurves()
{
readFlightCurves(trydata);
/*int n=0;
while(n!=1500)
{
printf(“%f\n“trydata[n]);
n++;
}*/
repaint();
int temp=0;
QPainter painter(this);
int i=0;
painter.setPen(QColor(02550));
painter.moveTo(xwidthyposition);
//画坐标轴
//在这里画出坐标轴
for(i=0;i<1500;i++)
{
trydata[i]=trydata[i]*Ylarge;//二十倍放大显示
//painter.drawLine(tempdata[i]temp+6data[i+1]);
painter.lineTo(i+xwidthyposition-trydata[i]);//对应原点坐标(20,400)
}
drawxy();
MoreBar = new QScrollBar(Qt::Horizontalthis);
MoreBar->setGeometry(20 460 400 20);
MoreBar->setMaxValue(10);
connect(MoreBar SIGNAL(nextLine()) this SLOT(showAfter()));
connect(MoreBar SIGNAL(prevLine()) this SLOT(showBefore()));
}
void Curves::emitscreen()
{
exit(-1);
}
void Curves::showAfter()
{
repaint();
int i=0;
int temp;
number=number+30;
WIDTH=xwidth+30;
QPainter painter(this);
temp=number;
painter.setPen(QColor(02550));
painter.moveTo(xwidthyposition);
for(i=0;i {
//painter.drawLine(tempdata[i]temp+6data[i+1]);
painter.lineTo(i+xwidthyposition-trydata[temp]);
temp++;
}
}
void Curves::showBefore()
{
repaint();
int i=0;
int temp=0;
nu
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 3400 2013-05-27 18:51 readt-x86\.moc\release-shared\moc_curves.cpp
I.A.... 2639 2013-05-27 18:51 readt-x86\.moc\release-shared\moc_CurvesForm.cpp
I.A.... 6208 2013-05-27 18:51 readt-x86\.obj\release-shared\Curves.o
I.A.... 4504 2013-05-27 18:51 readt-x86\.obj\release-shared\CurvesForm.o
I.A.... 11280 2013-05-27 18:51 readt-x86\.obj\release-shared\main.o
I.A.... 12036 2013-05-27 18:51 readt-x86\.obj\release-shared\moc_curves.o
I.A.... 11264 2013-05-27 18:51 readt-x86\.obj\release-shared\moc_CurvesForm.o
I.A.... 2049 2013-05-27 18:51 readt-x86\.ui\release-shared\CurvesForm.cpp
I.A.... 909 2013-05-27 18:51 readt-x86\.ui\release-shared\CurvesForm.h
I.A.... 1156 2013-05-27 18:51 readt-x86\a.txt
I.A.... 170 2013-05-27 18:51 readt-x86\build
I.A.... 45211 2013-05-27 18:51 readt-x86\curves
I.A.... 3391 2013-05-27 18:51 readt-x86\Curves.cpp
I.A.... 101 2013-05-27 18:51 readt-x86\curves.desktop
I.A.... 804 2013-05-27 18:51 readt-x86\curves.h
I.A.... 3405 2013-05-27 18:51 readt-x86\curves.png
I.A.... 165 2013-05-27 18:51 readt-x86\curves.pro
I.A.... 3352 2013-06-05 11:06 readt-x86\CurvesForm.ui
I.A.... 128 2013-05-27 18:51 readt-x86\file.txt
I.A.... 106 2013-05-27 18:51 readt-x86\main.cpp
I.A.... 12022 2013-05-27 18:51 readt-x86\Makefile
I.A.... 13329 2013-05-27 18:51 readt-x86\test.txt
I.A.... 14829 2013-05-27 18:51 readt-x86\test2.txt
I..D... 0 2013-05-27 18:51 readt-x86\.moc\release-shared
I..D... 0 2013-05-27 18:51 readt-x86\.obj\release-shared
I..D... 0 2013-05-27 18:51 readt-x86\.ui\release-shared
I..D... 0 2013-05-27 18:51 readt-x86\.moc
I..D... 0 2013-05-27 18:51 readt-x86\.obj
I..D... 0 2013-05-27 18:51 readt-x86\.ui
I..D... 0 2013-05-27 18:51 readt-x86
............此处省略3个文件信息
- 上一篇:韦东山电子相册代码
- 下一篇:8086仿真-LCD12864
相关资源
- Ubuntu下操作Excel,qt代码
- Qt图片浏览器 --基于Qt的Graphics View f
- qtnribbon2破解
- Qt软件开发 完整项目代码
- MQTT_3.1protocol_Specific中文版
- 在QT中使用RTP进行视频的采集和传输
- Mini6410 Qt4和Qtopia编程开发指南
- Qt实现Code39条形码
- qt_ffmpeg_mp4_export_and_import.zip
- QT5.5入门与项目实战
- Huffman Compress 霍夫曼编码 压缩 解压缩
- 基于QT的黑白棋游戏设计和实现
- Qt写的连连看小游戏
- QTranslate_6.7.2.7z
- Qt基于FFmpeg播放本地 H.264H264文件
- QT编的MP3播放器
- linux系统的二级文件系统(QT实现了简
- QT生成DLL库文件的方法和使用方法详解
- QT+opencv+OCR 身份证号码,银行卡号识别
- Qt实现的简单的中国象棋程序
- Qt时钟Demo,在原来基础上添加了秒针
- 基于Qt和opencv的身份证号码识别系统
- 基于FFmpeg4.0.2的AAC编码器
- Qt写的Windows下屏幕录制程序源码
- QT旅游攻略软件程序源代码
- mp4_play.zip
- ffmpeg+qt的简单播放器
- MyPeppa_Release_V1.0.rar
- 从零开始学习音视频编程技术十二 录
- Qt 日历可显示阴历生宵和时钟基于Q
评论
共有 条评论