QObject::startTimer: Timers can only be used with threads started with QThread

问题:
qt程序报错:QObject::startTimer: Timers can only be used with threads started with QThread

原因:
定时器启动函数startTimer的调用操作必须是在main函数中app定义的后面,如下:

    QGuiApplication app(argc, argv);
	// 定时器启动函数必须在app后调用
	timer.startTimer(3000);

猜你喜欢

转载自blog.csdn.net/qq_43248127/article/details/113060167