注册 登录
编程论坛 QT论坛

QT程序出错,三天找不到原因,被老板批了

flyingucla 发布于 2012-07-13 11:18, 1150 次点击
头文件
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtGui>
//#include <QPalette>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
//#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
//#include <sys/select.h>
#include <sys/time.h>
#include <errno.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
    Q_OBJECT   
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow()  
private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
源文件
#include "mainwindow.h"
#include "ui_mainwindow.h"
int buttons_fd;
char buttons[4] = {'0', '0', '0', '0'};
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    buttons_fd = open("/dev/buttons", 0);
    if (buttons_fd < 0) {
    perror("open device buttons");
    exit(1);
    }
    for (;;) {
    char current_buttons[6];
    int count_of_changed_key;
    int i;
    if (read(buttons_fd, current_buttons, sizeof current_buttons) != sizeof current_buttons)
    {
    perror("read buttons:");
    exit(1);
    }
    for (i = 0, count_of_changed_key = 0; i < sizeof buttons / sizeof buttons[0]; i++) {
    if (buttons != current_buttons) {
    buttons = current_buttons;


    count_of_changed_key++;
    }
    }
    if (count_of_changed_key) {
    printf("\n");
    }
    }
}
MainWindow::~MainWindow()
{
    delete ui;
}
运行时出现错误为1:permission denied  
2:collect2:1d returned 1 exit status
2 回复
#2
粉红木耳2012-08-05 10:45
哈哈 我是菜鸟, 你等老鸟吧!
#3
qsy1012012-11-19 11:00
“permission denied  ”
1.你运行了相同的程序,但是没有关闭
2.没有修改属性为可读
1