timer->start() too many arguments to function call error
-
wrote on 20 May 2021, 13:27 last edited by
Hello, I needa timer with 100 msec period. When I create and start the timer with 100 msec period as follow, I get: "too many arguments to functionall call, expected 0, have 1" error...
CAN::CAN(QObject *parent) : QObject(parent) { timer = new QTimer(this); connect(timer, &QTimer::timeout, this, &CAN::timerSlot); timer->start(100);
Even in the docs, it says that function requires parameters. I don't know what is wrong with that code block.
-
Hello, I needa timer with 100 msec period. When I create and start the timer with 100 msec period as follow, I get: "too many arguments to functionall call, expected 0, have 1" error...
CAN::CAN(QObject *parent) : QObject(parent) { timer = new QTimer(this); connect(timer, &QTimer::timeout, this, &CAN::timerSlot); timer->start(100);
Even in the docs, it says that function requires parameters. I don't know what is wrong with that code block.
-
@Gunkut
void start(std::chrono::milliseconds msec)
std::chrono::miliseconds
What you need is:timer->setInterval(100); timer->start();
@artwaw said in timer->start() too many arguments to function call error:
What you need is:
https://doc.qt.io/qt-6/qtimer.html#start
@Gunkut said in timer->start() too many arguments to function call error:
Hello, I needa timer with 100 msec period. When I create and start the timer with 100 msec period as follow, I get: "too many arguments to functionall call, expected 0, have 1" error...
Can you copy here the exact error, also please show the prototype of
CAN::timerSlot
. -
@artwaw said in timer->start() too many arguments to function call error:
What you need is:
https://doc.qt.io/qt-6/qtimer.html#start
@Gunkut said in timer->start() too many arguments to function call error:
Hello, I needa timer with 100 msec period. When I create and start the timer with 100 msec period as follow, I get: "too many arguments to functionall call, expected 0, have 1" error...
Can you copy here the exact error, also please show the prototype of
CAN::timerSlot
.wrote on 20 May 2021, 14:15 last edited by@kshegunov I think timer->start() does not accept any arguments. So using setInterval() fixed it. I couldn't catch that in docs though
-
@kshegunov I think timer->start() does not accept any arguments. So using setInterval() fixed it. I couldn't catch that in docs though
@Gunkut said in timer->start() too many arguments to function call error:
@kshegunov I think timer->start() does not accept any arguments. So using setInterval() fixed it. I couldn't catch that in docs though
Exactly what was my point (about the docs). Could you please share your Qt version, and also can you check in the headers if that method is declared? If it is not then it's a bug in the documentation, which we should report/fix. Thanks.
-
wrote on 20 May 2021, 14:17 last edited by
@Gunkut said in timer->start() too many arguments to function call error:
hat was not mentioned in docs. Thanks.
Which Qt-Version are you using?
As written in documentation ,void QTimer::start(std::chrono::milliseconds msec)
is only available for Qt 5.8 and higher.
1/7