Pregunta

I just started using Qt and learned of QTimers. Unfortunately, they seem to give an error and I have not seen this error described online yet:

error: C2514: 'QTimer' : class has no constructors.

I have my QTimer declared in the private section of dialog.h :

QTimer* timer;

And I instantiate it as such:

timer = new QTimer(this);

in dialog.cpp.

As this error does not show many results in a google search I am convinced I did something unthinkably dumb, but I have no idea what it is that I did wrong. Could someone please explain to me what it was that I did?

¿Fue útil?

Solución

So in your .h file you should have

QTimer * timer;

and in your constructor you should have

timer = new QTimer();

and at the top of your header file you should have:

#include <QTimer>

And you shouldn't have any of your own classes named QTimer.

Hope that helps.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top