?? frmtest.cpp
字號:
#include "frmtest.h"#include <stdio.h>#include <fcntl.h>#include <unistd.h>#define LED_DEV "/dev/emdoor_8led"/* * Constructs a frmtest which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */frmtest::frmtest( QWidget* parent, const char* name, bool modal, WFlags fl ) : Formtest( parent, name, modal, fl ){ DispTimer=new QTimer(this); connect ( btnOpen, SIGNAL(clicked()), this, SLOT(OpenDevice())); connect ( btnClose,SIGNAL(clicked()), this, SLOT(CloseDevice())); connect ( btnExit,SIGNAL(clicked()), this, SLOT(close())); connect (btnDisplay, SIGNAL(clicked()), this,SLOT(Display())); connect (btnStop, SIGNAL(clicked()), this,SLOT(StopDisplay())); connect ( DispTimer, SIGNAL(timeout()),this,SLOT(DisplayTimer())); fd=-1; led=0xff; flag=FALSE; }/* * Destroys the object and frees any allocated resources */frmtest::~frmtest(){ if(fd>0) { ::close(fd); fd=-1; } // no need to delete child widgets, Qt does it all for us}void frmtest::OpenDevice(){ if(fd<0) fd = ::open(LED_DEV, O_RDWR); else qDebug("The Device is opened!!"); }void frmtest::CloseDevice(){ if(fd>0) { ::close(fd); fd=-1; } }void frmtest::Display(){ DispTimer->start(500);}void frmtest::StopDisplay(){ DispTimer->stop();}void frmtest::DisplayTimer(){ flag=!flag; if(flag==TRUE) led=0xff; else led=0x0; if(fd>0) write(fd, &led, 1);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -