QT程序出错,三天找不到原因,被老板批了
头文件#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