Important: Please read the Qt Code of Conduct -

How to use QTimer connect without Object and without slot

  • Could you please share details on using connect function call without object and without slot.

    When I am trying below connect call: where in i want to use QTimer without a class object and without slot
    QObject::connect(pTimerUpdateScheduleTimeout, &QTimer::timeout,NULL, UpdateScheduleEvent());

    I am getting below error:
    error: invalid use of void expression
    QObject::connect(pTimerValidateScheduleTimeout, &QTimer::timeout,NULL, ValidateScheduleEvent())

    could you please help on above error.


  • ValidateScheduleEvent() calls the function and pass the result back to connect as an argument. what you want is taking the function pointer: QObject::connect(pTimerValidateScheduleTimeout, &QTimer::timeout,&ValidateScheduleEvent);

  • Hi,
    You can use QTimer with lamda functions like this.

    connect(pTimerValidateScheduleTimeoutr, &QTimer::timeout, []() {

Log in to reply