使用QT5完成一个数据实时显示控制的Demo
项目的需要,需要使用qt编写一个arm端的图形操作界面,完成雷达数据实时动态显示以及控制的功能,数据是自己模拟的,是xy坐标的点数据。先在window版本的qt上搭建简单框架测试通过,如下:
TestUiTheme-pro
#-------------------------------------------------
#
# Project created by 西电1603-WYC 2018-12-13T16:12:18
#
#-------------------------------------------------
QT += core gui
QT += charts
requires(qtConfig(combobox))
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TestUiTheme
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
target.path = $$[QT_INSTALL_EXAMPLES]/charts/chartthemes
INSTALLS += target
SOURCES += main.cpp\
mainwindow.cpp \
themewidget.cpp
HEADERS += mainwindow.h \
themewidget.h
FORMS += mainwindow.ui \
themewidget.ui
main.cpp
#include "mainwindow.h"
#include <QApplication>
#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "themewidget.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
QList<float> daa;
QList<float> daas;
int dd;
int dds;
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
void on_pushButton_4_clicked();
public slots:
void handleTimeout();
private:
Ui::MainWindow *ui;
themeWidget *xx;
QTimer *m_timer;
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QTimer"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
dd = 1,dds = 1;
xx = ui->widget;
m_timer = new QTimer(this);
m_timer->setSingleShot(false);
connect(m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
for(int s = 0;s<10;s++){
daa.append(s*1.0*dd);
}
QList<float>::iterator iter;
for(iter = daa.begin();iter != daa.end();iter+=2){
ui->textBrowser->append(QString("%1").arg(*iter)+","+QString("%1").arg(*iter+1));
}
dd++;
xx->fromMain(daa);
}
void MainWindow::on_pushButton_2_clicked()
{
ui->textBrowser->setPlainText("");
daa.clear();
daas.clear();
xx->clearALL();
}
void MainWindow::on_pushButton_3_clicked()
{
m_timer->start(2*1000);
}
void MainWindow::handleTimeout(){
for(int s = 0;s<2;s++){
daas.append((s+dds)*1.0*dds);
}
ui->textBrowser->setPlainText("");
QList<float>