主题 : 错误:请求从 ‘int’ 转换到非标量类型 ‘QList<QByteArray>’怎么解决啊? 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 104518
精华: 0
发帖: 12
金钱: 65 两
威望: 13 点
综合积分: 24 分
注册时间: 2014-05-27
最后登录: 2015-05-27
楼主  发表于: 2014-08-05 11:07

 错误:请求从 ‘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;
         //   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::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}