1. 程式人生 > >六維力感測器資料採集介面程式設計

六維力感測器資料採集介面程式設計

本文以vs2010+qt 程式設計,安裝qwt外掛,設計介面如圖所示,以正弦訊號模擬感測器接收的資料,執行效果如下所示. 在這裡插入圖片描述 由於力感測器相關軟體訊號採集只能在ubuntu的Clion下,所以需要將相關檔案複製拷貝到其專案中,需要的檔案有: 在這裡插入圖片描述 其中moc_xx.cpp改成moc_xx.h, 將其在mywidget.cpp中引用,因為qt編譯是用Qmake,而Clion是用Cmake, 如果沒加會出現以下錯誤: 在這裡插入圖片描述 Q_OBJECT未定義,若將Q_OBJECT刪掉,則QT基本的訊號和槽功能不能實現: 在這裡插入圖片描述 所以必須加上上述檔案moc_xx.h, 在這裡插入圖片描述 設計步驟:

  1. 參考我的基於vs2010+qt計算器設計介面,新增qwtplot控制元件,新增開始和結束按鈕,分別命好名qwtPlot_X qwtPlot_Y qwtPlot_Z qwtPlot_RX qwtPlot_RY qwtPlot_RZ
  2. 新增click響應和自定義槽函式start()和finish() 在這裡插入圖片描述 在這裡插入圖片描述 在這裡插入圖片描述 執行即可出現介面 3.重新定義QWTPLOT屬性 在這裡插入圖片描述 在這裡插入圖片描述 定義模擬訊號的函式Getdata 和更新qwtplot_x的函式,其中updatadataSlot_X()是實時顯示動態曲線的關鍵 在這裡插入圖片描述 在start()裡新增connect(),連線訊號和槽 在這裡插入圖片描述 此時執行可出現第一張影象 動態顯示正弦曲線的相關程式碼

mywidget.h如下:


#ifndef MYWIDGET_H
#define MYWIDGET_H

#include <QtWidgets/QWidget>
#include "ui_mywidget.h"
#include <QTimer>
#include <QTime>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_legend.h>
#include <math.h>
#include <qwt_plot_zoomer.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_magnifier.h>
#include <qwt_plot_grid.h>
#include <qwt_scale_draw.h>

class mywidget : public QWidget
{
	Q_OBJECT

public:
	mywidget(QWidget *parent = 0);
	~mywidget();

public:
	void setupqwt_X(QwtPlot* qwtplot); //設定QWTPLOT的屬性
	void setupqwt_Y(QwtPlot* qwtplot);
	void setupqwt_Z(QwtPlot* qwtplot);
	void setupqwt_RX(QwtPlot* qwtplot);
	void setupqwt_RY(QwtPlot* qwtplot);
	void setupqwt_RZ(QwtPlot* qwtplot);
public:

	QVector<double> t_data;
	QVector<double> X_data;
	QVector<double> Y_data;
	QVector<double> Z_data;
	QVector<double> RX_data;
	QVector<double> RY_data;
	QVector<double> RZ_data;


	QTimer updateTimer;

	QwtPlotCurve *curve_X ;
	QwtPlotCurve *curve_Y ;
	QwtPlotCurve *curve_Z ;
	QwtPlotCurve *curve_RX ;
	QwtPlotCurve *curve_RY ;
	QwtPlotCurve *curve_RZ ;

	double getData_X(double );
	double getData_Y(double );
	double getData_Z(double );
	double getData_RX(double );
	double getData_RY(double );
	double getData_RZ(double );


public slots:
	void updatedataSlot_X();
	void updatedataSlot_Y();
	void updatedataSlot_Z();
	void updatedataSlot_RX();
	void updatedataSlot_RY();
	void updatedataSlot_RZ();
	void start();
	void finish();

	

private:
	Ui::mywidgetClass ui;

};

#endif // MYWIDGET_H

mywidget.cpp如下:

#include "mywidget.h"

mywidget::mywidget(QWidget *parent)
	: QWidget(parent)
{
	ui.setupUi(this);
	setupqwt_X(ui.qwtPlot_X);
	setupqwt_Y(ui.qwtPlot_Y);
	setupqwt_Z(ui.qwtPlot_Z);
	setupqwt_RX(ui.qwtPlot_RX);
	setupqwt_RY(ui.qwtPlot_RY);
	setupqwt_RZ(ui.qwtPlot_RZ);
}

mywidget::~mywidget()
{

}

void mywidget::setupqwt_X(QwtPlot* qwtplot)
{
	//初始化xdata,x對應長度為5的座標,y初始全為0
	for(int i=1;i<5001;i++)
	{
		t_data.append(double(i)/1000-5);
		X_data.append(0);
	}	
	qwtplot->setTitle("The force of X");
	qwtplot->setCanvasBackground(Qt::gray);//背景

	//新增曲線
	curve_X = new QwtPlotCurve();
	curve_X->setPen( Qt::yellow, 1 ); //曲線的顏色 寬度;

	QTime curtime;
	curtime=curtime.currentTime();

	//設定刻度
	qwtplot->setAxisScale(QwtPlot::yLeft,-2,2,1); //設定刻度範圍-2到2,間隔是1
	qwtplot->setAxisScale(QwtPlot::xBottom,-5,0,1);

	//設定網格
	QwtPlotGrid *grid = new QwtPlotGrid();
	grid->enableX( true );//設定網格線
	grid->enableY( true );
	grid->setMajorPen( Qt::black, 0, Qt::DotLine );
	grid->attach(qwtplot);

	//時間
	//connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_X()));
	//updateTimer.start(0);

}
//模擬資料
double mywidget::getData_X(double time)
{
	double s = 2*qCos( time * (M_PI * 2 )+ M_PI/3 ) ;
	return s;
}

void mywidget::updatedataSlot_X()
{
	static QTime dataTime(QTime::currentTime());
	long int eltime = dataTime.elapsed();
	static int lastpointtime = 0;

	int size = (eltime - lastpointtime);


	if(size>0)
	{    
		//有資料傳入
		X_data.erase(X_data.begin(),X_data.begin()+size);//擦除多餘的資料
		for(int i=1;i<size+1;i++)
		{
			X_data.append(getData_X((((double)lastpointtime+i)/1000)));
		}
		lastpointtime = eltime;
	}

	curve_X->setSamples(t_data, X_data);
	curve_X->attach(ui.qwtPlot_X);

	ui.qwtPlot_X->replot();
}

void mywidget::setupqwt_Y(QwtPlot* qwtplot)
{
	//初始化xdata,x對應長度為5的座標,y初始全為0
	for(int i=1;i<5001;i++)
	{
		t_data.append(double(i)/1000-5);
		Y_data.append(0);
	}	
	qwtplot->setTitle("The force of Y");
	qwtplot->setCanvasBackground(Qt::gray);//背景

	//新增曲線
	curve_Y = new QwtPlotCurve();
	curve_Y->setPen( Qt::yellow, 1 ); //曲線的顏色 寬度;

	QTime curtime;
	curtime=curtime.currentTime();

	//設定刻度
	qwtplot->setAxisScale(QwtPlot::yLeft,-2,2,1); //設定刻度範圍-2到2,間隔是1
	qwtplot->setAxisScale(QwtPlot::xBottom,-5,0,1);

	//設定網格
	QwtPlotGrid *grid = new QwtPlotGrid();
	grid->enableX( true );//設定網格線
	grid->enableY( true );
	grid->setMajorPen( Qt::black, 0, Qt::DotLine );
	grid->attach(qwtplot);

	//時間
	//connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_Y()));
	//updateTimer.start(0);

}
//模擬資料
double mywidget::getData_Y(double time)
{
	double s = qCos( time * M_PI * 2 ) ;
	return s;
}

void mywidget::updatedataSlot_Y()
{
	static QTime dataTime(QTime::currentTime());
	long int eltime = dataTime.elapsed();
	static int lastpointtime = 0;

	int size = (eltime - lastpointtime);


	if(size>0)
	{    
		//有資料傳入
		Y_data.erase(Y_data.begin(),Y_data.begin()+size);//擦除多餘的資料
		for(int i=1;i<size+1;i++)
		{
			Y_data.append(getData_Y((((double)lastpointtime+i)/1000)));
		}
		lastpointtime = eltime;
	}

	curve_Y->setSamples(t_data, Y_data);
	curve_Y->attach(ui.qwtPlot_Y);

	ui.qwtPlot_Y->replot();
}


void mywidget::setupqwt_Z(QwtPlot* qwtplot)
{
	//初始化xdata,x對應長度為5的座標,y初始全為0
	for(int i=1;i<5001;i++)
	{
		t_data.append(double(i)/1000-5);
		Z_data.append(0);
	}	
	qwtplot->setTitle("The force of Z");
	qwtplot->setCanvasBackground(Qt::gray);//背景

	//新增曲線
	curve_Z = new QwtPlotCurve();
	curve_Z->setPen( Qt::yellow, 1 ); //曲線的顏色 寬度;

	QTime curtime;
	curtime=curtime.currentTime();

	//設定刻度
	qwtplot->setAxisScale(QwtPlot::yLeft,-2,2,1); //設定刻度範圍-2到2,間隔是1
	qwtplot->setAxisScale(QwtPlot::xBottom,-5,0,1);

	//設定網格
	QwtPlotGrid *grid = new QwtPlotGrid();
	grid->enableX( true );//設定網格線
	grid->enableY( true );
	grid->setMajorPen( Qt::black, 0, Qt::DotLine );
	grid->attach(qwtplot);

	//時間
	//connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_Z()));
	//updateTimer.start(0);

}
//模擬資料
double mywidget::getData_Z(double time)
{
	double s = 0.5*qSin( time * M_PI * 2 ) ;
	return s;
}

void mywidget::updatedataSlot_Z()
{
	static QTime dataTime(QTime::currentTime());
	long int eltime = dataTime.elapsed();
	static int lastpointtime = 0;

	int size = (eltime - lastpointtime);


	if(size>0)
	{    
		//有資料傳入
		Z_data.erase(Z_data.begin(),Z_data.begin()+size);//擦除多餘的資料
		for(int i=1;i<size+1;i++)
		{
			Z_data.append(getData_Z((((double)lastpointtime+i)/1000)));
		}
		lastpointtime = eltime;
	}

	curve_Z->setSamples(t_data, Z_data);
	curve_Z->attach(ui.qwtPlot_Z);

	ui.qwtPlot_Z->replot();
}


void mywidget::setupqwt_RX(QwtPlot* qwtplot)
{
	//初始化xdata,x對應長度為5的座標,y初始全為0
	for(int i=1;i<5001;i++)
	{
		t_data.append(double(i)/1000-5);
		RX_data.append(0);
	}	
	qwtplot->setTitle("The force of RX");
	qwtplot->setCanvasBackground(Qt::gray);//背景

	//新增曲線
	curve_RX = new QwtPlotCurve();
	curve_RX->setPen( Qt::yellow, 1 ); //曲線的顏色 寬度;

	QTime curtime;
	curtime=curtime.currentTime();

	//設定刻度
	qwtplot->setAxisScale(QwtPlot::yLeft,-2,2,1); //設定刻度範圍-2到2,間隔是1
	qwtplot->setAxisScale(QwtPlot::xBottom,-5,0,1);

	//設定網格
	QwtPlotGrid *grid = new QwtPlotGrid();
	grid->enableX( true );//設定網格線
	grid->enableY( true );
	grid->setMajorPen( Qt::black, 0, Qt::DotLine );
	grid->attach(qwtplot);

	//時間
	//connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_RX()));
	//updateTimer.start(0);

}
//模擬資料
double mywidget::getData_RX(double time)
{
	double s = qSin( time * M_PI * 2 ) ;
	return s;
}

void mywidget::updatedataSlot_RX()
{
	static QTime dataTime(QTime::currentTime());
	long int eltime = dataTime.elapsed();
	static int lastpointtime = 0;

	int size = (eltime - lastpointtime);


	if(size>0)
	{    
		//有資料傳入
		RX_data.erase(RX_data.begin(),RX_data.begin()+size);//擦除多餘的資料
		for(int i=1;i<size+1;i++)
		{
			RX_data.append(getData_RX((((double)lastpointtime+i)/1000)));
		}
		lastpointtime = eltime;
	}

	curve_RX->setSamples(t_data, RX_data);
	curve_RX->attach(ui.qwtPlot_RX);

	ui.qwtPlot_RX->replot();
}

void mywidget::setupqwt_RY(QwtPlot* qwtplot)
{
	//初始化xdata,x對應長度為5的座標,y初始全為0
	for(int i=1;i<5001;i++)
	{
		t_data.append(double(i)/1000-5);
		RY_data.append(0);
	}	
	qwtplot->setTitle("The force of RY");
	qwtplot->setCanvasBackground(Qt::gray);//背景

	//新增曲線
	curve_RY = new QwtPlotCurve();
	curve_RY->setPen( Qt::yellow, 1 ); //曲線的顏色 寬度;

	QTime curtime;
	curtime=curtime.currentTime();

	//設定刻度
	qwtplot->setAxisScale(QwtPlot::yLeft,-2,2,1); //設定刻度範圍-2到2,間隔是1
	qwtplot->setAxisScale(QwtPlot::xBottom,-5,0,1);

	//設定網格
	QwtPlotGrid *grid = new QwtPlotGrid();
	grid->enableX( true );//設定網格線
	grid->enableY( true );
	grid->setMajorPen( Qt::black, 0, Qt::DotLine );
	grid->attach(qwtplot);

	//時間
	//connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_RY()));
	//updateTimer.start(0);

}
//模擬資料
double mywidget::getData_RY(double time)
{
	double s = qSin( time * M_PI * 2 ) ;
	return s;
}

void mywidget::updatedataSlot_RY()
{
	static QTime dataTime(QTime::currentTime());
	long int eltime = dataTime.elapsed();
	static int lastpointtime = 0;

	int size = (eltime - lastpointtime);


	if(size>0)
	{    
		//有資料傳入
		RY_data.erase(RY_data.begin(),RY_data.begin()+size);//擦除多餘的資料
		for(int i=1;i<size+1;i++)
		{
			RY_data.append(getData_RY((((double)lastpointtime+i)/1000)));
		}
		lastpointtime = eltime;
	}

	curve_RY->setSamples(t_data, RY_data);
	curve_RY->attach(ui.qwtPlot_RY);

	ui.qwtPlot_RY->replot();
}

void mywidget::setupqwt_RZ(QwtPlot* qwtplot)
{
	//初始化xdata,x對應長度為5的座標,y初始全為0
	for(int i=1;i<5001;i++)
	{
		t_data.append(double(i)/1000-5);
		RZ_data.append(0);
	}	
	qwtplot->setTitle("The force of RZ");
	qwtplot->setCanvasBackground(Qt::gray);//背景

	//新增曲線
	curve_RZ = new QwtPlotCurve();
	curve_RZ->setPen( Qt::yellow, 1 ); //曲線的顏色 寬度;

	QTime curtime;
	curtime=curtime.currentTime();

	//設定刻度
	qwtplot->setAxisScale(QwtPlot::yLeft,-2,2,1); //設定刻度範圍-2到2,間隔是1
	qwtplot->setAxisScale(QwtPlot::xBottom,-5,0,1);

	//設定網格
	QwtPlotGrid *grid = new QwtPlotGrid();
	grid->enableX( true );//設定網格線
	grid->enableY( true );
	grid->setMajorPen( Qt::black, 0, Qt::DotLine );
	grid->attach(qwtplot);

	//時間
	//connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_RZ()));
	//updateTimer.start(0);

}
//模擬資料
double mywidget::getData_RZ(double time)
{
	double s = qSin( time * M_PI * 2 ) ;
	return s;
}

void mywidget::updatedataSlot_RZ()
{
	static QTime dataTime(QTime::currentTime());
	long int eltime = dataTime.elapsed();
	static int lastpointtime = 0;

	int size = (eltime - lastpointtime);


	if(size>0)
	{    
		//有資料傳入
		RZ_data.erase(RZ_data.begin(),RZ_data.begin()+size);//擦除多餘的資料
		for(int i=1;i<size+1;i++)
		{
			RZ_data.append(getData_RZ((((double)lastpointtime+i)/1000)));
		}
		lastpointtime = eltime;
	}

	curve_RZ->setSamples(t_data, RZ_data);
	curve_RZ->attach(ui.qwtPlot_RZ);

	ui.qwtPlot_RZ->replot();
}

void mywidget::start()
{
	updateTimer.start(0);
	connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_X()));
	connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_Y()));
	connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_Z()));
	connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_RX()));
	connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_RY()));
	connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_RZ()));

}
void mywidget::finish()
{
	disconnect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_X()));
	disconnect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_Y()));
	disconnect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_Z()));
	disconnect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_RX()));
	disconnect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_RY()));
	disconnect(&updateTimer,SIGNAL(timeout()),this,SLOT(updatedataSlot_RZ()));

}

ui_mywidget.h如下:

/********************************************************************************
** Form generated from reading UI file 'mywidget.ui'
**
** Created by: Qt User Interface Compiler version 5.3.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/

#ifndef UI_MYWIDGET_H
#define UI_MYWIDGET_H

#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QWidget>
#include "qwt_plot.h"

QT_BEGIN_NAMESPACE

class Ui_mywidgetClass
{
public:
    QwtPlot *qwtPlot_X;
    QwtPlot *qwtPlot_RX;
    QwtPlot *qwtPlot_RY;
    QwtPlot *qwtPlot_Y;
    QwtPlot *qwtPlot_Z;
    QwtPlot *qwtPlot_RZ;
    QPushButton *pushButton_star;
    QPushButton *pushButton_finish;

    void setupUi(QWidget *mywidgetClass)
    {
        if (mywidgetClass->objectName().isEmpty())
            mywidgetClass->setObjectName(QStringLiteral("mywidgetClass"));
        mywidgetClass->resize(1514, 929);
        qwtPlot_X = new QwtPlot(mywidgetClass);
        qwtPlot_X->setObjectName(QStringLiteral("qwtPlot_X"));
        qwtPlot_X->setGeometry(QRect(30, 40, 631, 221));
        qwtPlot_RX = new QwtPlot(mywidgetClass);
        qwtPlot_RX->setObjectName(QStringLiteral("qwtPlot_RX"));
        qwtPlot_RX->setGeometry(QRect(740, 40, 631, 221));
        qwtPlot_RY = new QwtPlot(mywidgetClass);
        qwtPlot_RY->setObjectName(QStringLiteral("qwtPlot_RY"));
        qwtPlot_RY->setGeometry(QRect(740, 320, 631, 221));
        qwtPlot_Y = new QwtPlot(mywidgetClass);
        qwtPlot_Y->setObjectName(QStringLiteral("qwtPlot_Y"));
        qwtPlot_Y->setGeometry(QRect(30, 320, 631, 221));
        qwtPlot_Z = new QwtPlot(mywidgetClass);
        qwtPlot_Z->setObjectName(QStringLiteral("qwtPlot_Z"));
        qwtPlot_Z->setGeometry(QRect(30, 600, 631, 221));
        qwtPlot_RZ = new QwtPlot(mywidgetClass);
        qwtPlot_RZ->setObjectName(QStringLiteral("qwtPlot_RZ"));
        qwtPlot_RZ->setGeometry(QRect(740, 600, 631, 221));
        pushButton_star = new QPushButton(mywidgetClass);
        pushButton_star->setObjectName(QStringLiteral("pushButton_star"));
        pushButton_star->setGeometry(QRect(310, 870, 75, 23));
        pushButton_finish = new QPushButton(mywidgetClass);
        pushButton_finish->setObjectName(QStringLiteral("pushButton_finish"));
        pushButton_finish->setGeometry(QRect(1040, 870, 75, 23));

        retranslateUi(mywidgetClass);
        QObject::connect(pushButton_star, SIGNAL(clicked()), mywidgetClass, SLOT(start()));
        QObject::connect(pushButton_finish, SIGNAL(clicked()), mywidgetClass, SLOT(finish()));

        QMetaObject::connectSlotsByName(mywidgetClass);
    } // setupUi

    void retranslateUi(QWidget *mywidgetClass)
    {
        mywidgetClass->setWindowTitle(QApplication::translate("mywidgetClass", "mywidget", 0));
        pushButton_star->setText(QApplication::translate("mywidgetClass", "\345\274\200\345\247\213", 0));
        pushButton_finish->setText(QApplication::translate("mywidgetClass", "\347\273\223\346\235\237", 0));
    } // retranslateUi

};

namespace Ui {
    class mywidgetClass: public Ui_mywidgetClass {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_MYWIDGET_H

moc_mywidget.cpp如下:

/****************************************************************************
** Meta object code from reading C++ file 'mywidget.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.3.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#include "../../mywidget.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'mywidget.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.3.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif

QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_mywidget_t {
    QByteArrayData data[10];
    char stringdata[128];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
    qptrdiff(offsetof(qt_meta_stringdata_mywidget_t, stringdata) + ofs \
        - idx * sizeof(QByteArrayData)) \
    )
static const qt_meta_stringdata_mywidget_t qt_meta_stringdata_mywidget = {
    {
QT_MOC_LITERAL(0, 0, 8),
QT_MOC_LITERAL(1, 9, 16),
QT_MOC_LITERAL(2, 26, 0),
QT_MOC_LITERAL(3, 27, 16),
QT_MOC_LITERAL(4, 44, 16),
QT_MOC_LITERAL(5, 61, 17),
QT_MOC_LITERAL(6, 79, 17),
QT_MOC_LITERAL(7, 97, 17),
QT_MOC_LITERAL(8, 115, 5),
QT_MOC_LITERAL(9, 121, 6)
    },
    "mywidget\0updatedataSlot_X\0\0updatedataSlot_Y\0"
    "updatedataSlot_Z\0updatedataSlot_RX\0"
    "updatedataSlot_RY\0updatedataSlot_RZ\0"
    "start\0finish"
};
#undef QT_MOC_LITERAL

static const uint qt_meta_data_mywidget[] = {

 // content:
       7,       // revision
       0,       // classname
       0,    0, // classinfo
       8,   14, // methods
       0,    0, // properties
       0,    0, // enums/sets
       0,    0, // constructors
       0,       // flags
       0,       // signalCount

 // slots: name, argc, parameters, tag, flags
       1,    0,   54,    2, 0x0a /* Public */,
       3,    0,   55,    2, 0x0a /* Public */,
       4,    0,   56,    2, 0x0a /* Public */,
       5,    0,   57,    2, 0x0a /* Public */,
       6,    0,   58,    2, 0x0a /* Public */,
       7,    0,   59,    2, 0x0a /* Public */,
       8,    0,   60,    2, 0x0a /* Public */,
       9,    0,   61,    2, 0x0a /* Public */,

 // slots: parameters
    QMetaType::Void,
    QMetaType::Void,
    QMetaType::Void,
    QMetaType::Void,
    QMetaType::Void,
    QMetaType::Void,
    QMetaType::Void,
    QMetaType::Void,

       0        // eod
};

void mywidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
    if (_c == QMetaObject::InvokeMetaMethod) {
        mywidget *_t = static_cast<mywidget *>(_o);
        switch (_id) {
        case 0: _t->updatedataSlot_X(); break;
        case 1: _t->updatedataSlot_Y(); break;
        case 2: _t->updatedataSlot_Z(); break;
        case 3: _t->updatedataSlot_RX(); break;
        case 4: _t->updatedataSlot_RY(); break;
        case 5: _t->updatedataSlot_RZ(); break;
        case 6: _t->start(); break;
        case 7: _t->finish(); break;
        default: ;
        }
    }
    Q_UNUSED(_a);
}

const QMetaObject mywidget::staticMetaObject = {
    { &QWidget::staticMetaObject, qt_meta_stringdata_mywidget.data,
      qt_meta_data_mywidget,  qt_static_metacall, 0, 0}
};


const QMetaObject *mywidget::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}

void *mywidget::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_mywidget.stringdata))
        return static_cast<void*>(const_cast< mywidget*>(this));
    return QWidget::qt_metacast(_clname);
}

int mywidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 8)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 8;
    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
        if (_id < 8)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 8;
    }
    return _id;
}
QT_END_MOC_NAMESPACE

二. 講相關檔案匯入ubuntu的專案中,感測器訊號傳遞如下: 在這裡插入圖片描述 在這裡插入圖片描述 在這裡插入圖片描述 在這裡插入圖片描述