在系统启动后,此时启动的进度条快达到100%,通过串口操作,将根目录下的tmp文件夹(/tmp)里面的所有文件和文件夹删除,注意不能将tmp文件夹删了;也可在向启动卡复制文件时,修改卡目录的权限(sudo chmod -R 777 /media/rootf)。
2、Qt下自行实现的Sleep()函数换一下,会使CPU使用率高达%90以上(http://blog.sina.com.cn/s/blog_74a459380102uwcb.html):
原来的为:
void sleepmsec(unsigned int msec) //以下这个代码主要是实现以毫秒为单位的延时
{
if(msec<=0)
return;
QTime dieTime = QTime::currentTime().addMSecs(msec);
while( QTime::currentTime() < dieTime ) //该处的循环会比较多的占用CPU
QCoreApplication::processEvents(QEventLoop::AllEvents, 100); //该处用空闲时间刷新循环事件,但效果没有下面的好
}
现更改为:
class SleeperThread:public QThread
{
public:
static void msleep(unsigned long msecs)
{
QThread::msleep(msecs);
}
};
void sleepmsec(unsigned int msec) //以下这个代码主要是实现以毫秒为单位的延时
{
if(msec<=0)
return;
SleeperThread::msleep(msec); //使用线程的延时,很好的降低CPU的使用率
}
3、
bool MainWindow::eventFilter(QObject *obj, QEvent *e)
{
if (obj == button) //响应button的MouseButtonPress和MouseButtonRelease事件
{
if (e->type() == QEvent::MouseButtonPress)
{
QMouseEvent *event = static_cast<QMouseEvent*> (e);
button->setText(QString("Press: %1, %2").arg(QString::number(event->x()), QString::number(event->y())));
return true;
}
else if (e->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *event = static_cast<QMouseEvent*> (e);
button->setText(QString("Release: %1, %2").arg(QString::number(event->x()), QString::number(event->y())));
return true;
}
else
{
return false;
}
}
return QMainWindow::eventFilter(obj, e);
}
//处理自定义事件:
bool CDlgMain::event(QEvent *event)
{
if (event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *e = static_cast<QMouseEvent*> (event);
QPoint point;
point.setX(e->x());
point.setY(e->y());
QRect qlRect = pPBBattery->geometry();
if(e->button() == Qt::LeftButton && qlRect.contains(point))
{
ShowLabelCurDataInfo();
}
//qDebug() << tr("CDlgMain::event----event->type() == QEvent::MouseButtonRelease---------");
}
}