原创 qt定时器事件例子

2010-2-27 09:38 3136 3 3 分类: MCU/ 嵌入式
#include <qapplication.h>
#include <qpushbutton.h>
#include <QWidget>
#include <QTextCodec>
#include <QLabel>
#include <QFont>
#include <QtGui/QTextEdit>
#include <QCursor>
#include <QTimerEvent>
#include "ui_hu.h"
class Win : public QWidget, public Ui::Form
{
 public:
      Win(QWidget *parent = 0):QWidget(parent)
      {
         TimerCount = 0;
         setupUi(this);
         startTimer(1000);
      }
 private:
      int TimerCount;
      void timerEvent(QTimerEvent* event);
};
void Win::timerEvent(QTimerEvent* event)
{
    TimerCount++;
    lcdNumber->setProperty("intValue", QVariant(TimerCount));
}

int main( int argc, char *argv[] )
{
    QApplication app(argc, argv);
    QFont font;
    font.setPointSize(50);
    font.setFamily(("simhei"));
    app.setFont(font);
    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));

    app.setOverrideCursor(QCursor(Qt::BlankCursor));//取消鼠标指针
 

     Win MainWin;
   
     MainWin.setWindowFlags(Qt::FramelessWindowHint);
     MainWin.show();
 
    return app.exec();
 
}

文章评论0条评论)

登录后参与讨论
我要评论
0
3
关闭 站长推荐上一条 /2 下一条