QT学习笔记-数据类型

来源:互联网 发布:oracle查找重复数据 编辑:程序博客网 时间:2024/04/30 06:14
QT编程QString与int类型转换

字符串转整型

int num;

num=a.toInt(str)


整型转字符串

QString str;
str=QString::number(num)


QT编程QTimer定时器代码

#ifndef MYTIME_H
#define MYTIME_H
#include <QTimer>
#include <QObject>
class MyTime : public QObject
{
    Q_OBJECT
public:
    MyTime(QObject *parent = NULL );
    ~MyTime();
signals:
public slots:
     void handleTimeout();
private:
    QTimer *m_pTimer;
};
#endif // MYTIME_H

#include "mytime.h"
#include <QTimer>
#include <QDebug>
#define TIMER_TIMEOUT 5000
MyTime::MyTime(QObject *parent) : QObject(parent)
{
    m_pTimer = new QTimer(this);
    connect(m_pTimer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
    m_pTimer->start(TIMER_TIMEOUT);
}
MyTime::~MyTime()
{
}
void MyTime::handleTimeout()
{
    qDebug()<<"Enter timeout processing function\n";
    if(m_pTimer->isActive())
    {
        m_pTimer->stop();
    }
}
 

原创粉丝点击