MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // file.setFileName("/home/firefly/123"); file.setFileName("/sys/class/leds/firefly:yellow:user/brightness"); // system("echo none > /sys/class/leds/firefly:yellow:user/trigger"); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked(bool checked) { qDebug()<<checked<<endl; if(!file.exists()) { qDebug()<<"no led"<<endl; return ; } if(!file.open(QIODevice::WriteOnly)) qDebug()<<file.errorString()<<endl; QByteArray buf[] = {"0","1"}; if(checked) { ui->pushButton->setText("close"); qDebug()<<"close"<<endl; file.write(buf[1]); } else { ui->pushButton->setText("open"); qDebug()<<"open"<<endl; file.write(buf[0]); } file.close(); } 在终端上 打开文件提示permission denied 尝试 chmod 777没有用 请问是什么问题呢 |
-
636.76 KB, 下载次数: 0, 下载积分: 灯泡 -1 , 经验 -1