标题:QT下如何对dev设备进行操作
作者:zjun726
日期:2013-05-20 10:24
内容:
micro2440开发板,显示界面已经基本设计完成了,接下来要对底层的设备进行操作,比如PWM等。
在网上找了很多源代码,基本上了解是通过open等函数进行操作,但是这些代码都用到了一个称为Form的类,里面有open等函数,
我的界面是用QWidget设计的啊,好像没有open这些函数啊,我用的Qte4.6.3
我把别人的代码用我的QtCreate编译,也通不过。
哪位大侠知道是怎么回事啊?
#1 [ywmlovecss 05-21 09:12]
操作设备肯定是linux下的那些函数了!!其他的肯定都是分装的。比如操作/dev/video0吧,直接用open(“/dev/video0”,xxx);如何与你使用的类里面也含有open函数发生冲突,直接在open的前面加上::操作符就可解决。例如::open(“/dev/video0”,xxx);记得包含头文件呀
#2 回 1楼(ywmlovecss) 的帖子 [zjun726 05-21 22:33]
谢谢。我就是在别人的例子里面看到是::open(),不明白是什么意思
#3 回 1楼(ywmlovecss) 的帖子 [zjun726 05-22 08:59]
刚刚试了一下,可是提示open was not declared in this scope. 我包含了头文件啊
源码如下:
#include "smartdelaywidget.h"
#include
#include
#include
#include
#include
#include
int main(int argc, char *argv[])
{
int fd;
QApplication a(argc, argv);
SmartDelayWidget w;
QWSServer::setCursorVisible(false); //hide the cursor
w.setWindowFlags(Qt::FramelessWindowHint);//hide the Window title
w.show();
fd = open("/dev/pwm", 0);
if (fd < 0) {
perror("open pwm_buzzer device");
exit(1);
}
return a.exec();
}
#4 回 2楼(zjun726) 的帖子 [ywmlovecss 05-22 09:06]
虽然我也不是太懂,但应该是位域的问题!!!
#5 回 3楼(zjun726) 的帖子 [ywmlovecss 05-22 09:08]
亲,open的头文件是#include
另外是::open,你看你加了吗???