Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to use QTimer connect without Object and without slot
Forum Updated to NodeBB v4.3 + New Features

How to use QTimer connect without Object and without slot

Scheduled Pinned Locked Moved Unsolved C++ Gurus
3 Posts 3 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrudula
    wrote on 14 Aug 2018, 14:55 last edited by
    #1

    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.

    Thanks,
    Mrudula

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 14 Aug 2018, 15:03 last edited by
      #2

      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);

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3
      • T Offline
        T Offline
        TobbY
        wrote on 12 Sept 2018, 15:14 last edited by
        #3

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

        connect(pTimerValidateScheduleTimeoutr, &QTimer::timeout, []() {
        ValidateScheduleEvent();
        });
        
        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved