您的位置:首页 > 游戏 > 游戏 > 网页制作的模板代码_工程项目信息查询_免费建站网站网页_怎么提高关键词搜索权重

网页制作的模板代码_工程项目信息查询_免费建站网站网页_怎么提高关键词搜索权重

2025/5/17 19:22:31 来源:https://blog.csdn.net/weixin_62130773/article/details/146261669  浏览:    关键词:网页制作的模板代码_工程项目信息查询_免费建站网站网页_怎么提高关键词搜索权重
网页制作的模板代码_工程项目信息查询_免费建站网站网页_怎么提高关键词搜索权重

主程序

#include <QCoreApplication>
#include "mainwindow.h"int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);MainWindow w;return a.exec();
}

mainwindow.cpp程序

#include "mainwindow.h"#include <QDateTime>MainWindow::MainWindow(QObject *parent):QObject(parent)
{pTimer = new QTimer(this);pTimer->setInterval(10000);connect(pTimer, &QTimer::timeout, this, &MainWindow::slot10000msTimeOut);pTimer->start();qDebug() << "Start constructing MainWindow at:" << QDateTime::currentDateTime();if (pTimer->isActive()) {qDebug() << "Timer started successfully.";} else {qDebug() << "Timer failed to start.";}
}
MainWindow::~MainWindow()
{if(pTimer->isActive()){pTimer->stop();}
}void MainWindow::slot10000msTimeOut()
{qDebug() << "End constructing MainWindow at:" << QDateTime::currentDateTime();
}

mainwindow.h头文件

#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include <QTimer>
#include <QDebug>
class MainWindow : public QObject
{Q_OBJECTpublic:MainWindow(QObject *parent = nullptr);~MainWindow();private:QTimer *pTimer;private slots:void slot10000msTimeOut();
};
#endif // MAINWINDOW_H

总结了注意点:

关闭定时器,在程序结束的时候,再stop

声明了槽函数,是必须要去定义的。否则报错

QCoreApplication不依赖于任何 GUI 相关的库和功能

 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com