报错文件为widget.cpp,原代码如下:
#include <memory>QLineEdit *frequency = new QLineEdit();QComboBox *cbBox_method = new QComboBox();QLineEdit *X_MAXvalue = new QLineEdit();QLineEdit *Y_MAXvalue = new QLineEdit();QLineEdit *X_MINvalue = new QLineEdit();QLineEdit *Y_MINvalue = new QLineEdit();QLineEdit *X_average = new QLineEdit();QLineEdit *Y_average = new QLineEdit();char fileName[256];FILE *fp=NULL;int k;unsigned short fileBuf[1024];int32 bFileHeaderSize=0;int32 byteSize=0;int32 historyFileLen=0;double voltData[1024];int32 pointsFetched=0;int32 chunksFetched=0;std::deque<double>datadeque;double voltage;int buff_busy=0;
Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);
}
问题在于,QObject变量是基于UI的变量,不能在Widget出现之前定义,应该定义在Widget之后