|
1Qter豆
本人初学QT编程,结合自己用的友善之臂tiny4412开发板编了一个三个AD通道的采集程序,运行发现错误,不知道怎么解决。
mainwindow.cpp:72: 错误:请求从 ‘int’ 转换到非标量类型 ‘QList<QByteArray>’
程序如下
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/fs.h>
#include <errno.h>
#include <string.h>
#define ADC_SET_CHANNEL 0xc000fa01
#define ADC_SET_ADCTSC 0xc000fa02
/*
1) cd Linux-2.6.38
2) make menuconfig
3) enter Device Drivers--->Input device support --->Touchscreens
4) unselect "S3C touchscreen driver for Mini6410"
5) make
*/
#define CHANNELCOUNT 6
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
int MainWindow::toDigit(int argc, char* argv[])
{
ui->lineEdit->clear();
ui->lineEdit_2->clear();
ui->lineEdit_3->clear();
QString oxygen1,wendu,ph;
int channels[CHANNELCOUNT] = {1,2,3}; //for 6410
// int channels[CHANNELCOUNT] = {0,1,6,7,8,9}; //for 210
int channel;
int i=0;
fprintf(stderr, "press Ctrl-C to stop\n");
int fd = open("/dev/adc", 0);
if (fd < 0) {
perror("open ADC device:");
return 1;
}
char output[255];
for(;;) {
puts("\033[2J");
output[0] = 0;
for (i=0; i<CHANNELCOUNT; i++) {
channel = channels[i];
// if (ioctl(fd, ADC_SET_CHANNEL, channel) < 0) {
// perror("Can't set channel for /dev/adc!");
// close(fd);
// return 1;
// }
char buffer[30];
int len = read(fd, buffer, sizeof buffer -1);
if (len > 0) {
buffer[len] = '\0';
int value = -1;
sscanf(buffer, "%d", &value);
QList<QString> AD= value;
oxygen1 = AD[0];
ui->lineEdit->setText(oxygen1);
wendu = AD[1];
ui->lineEdit_2->setText(wendu);
ph = AD[2];
ui->lineEdit_3->setText(ph);
} else {
::close(fd);
return 1;
}
}
usleep(300* 1000);
}
::close(fd);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent:anguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
|
最佳答案
查看完整内容
看错误像是你把int赋给了QString 转下吧
|