Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. timer->start() too many arguments to function call error
Forum Updated to NodeBB v4.3 + New Features

timer->start() too many arguments to function call error

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 916 Views 2 Watching
  • 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.
  • G Offline
    G Offline
    Gunkut
    wrote on 20 May 2021, 13:27 last edited by
    #1

    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.

    A 1 Reply Last reply 20 May 2021, 13:48
    0
    • G Gunkut
      20 May 2021, 13:27

      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.

      A Offline
      A Offline
      artwaw
      wrote on 20 May 2021, 13:48 last edited by
      #2

      @Gunkut
      void start(std::chrono::milliseconds msec)
      std::chrono::miliseconds
      What you need is:

      timer->setInterval(100);
      timer->start();
      

      For more information please re-read.

      Kind Regards,
      Artur

      K 1 Reply Last reply 20 May 2021, 13:54
      0
      • A artwaw
        20 May 2021, 13:48

        @Gunkut
        void start(std::chrono::milliseconds msec)
        std::chrono::miliseconds
        What you need is:

        timer->setInterval(100);
        timer->start();
        
        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 20 May 2021, 13:54 last edited by
        #3

        @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.

        Read and abide by the Qt Code of Conduct

        G 1 Reply Last reply 20 May 2021, 14:15
        1
        • G Offline
          G Offline
          Gunkut
          wrote on 20 May 2021, 14:11 last edited by
          #4

          @artwaw yeah that solved the issue. That was not mentioned in docs. Thanks.

          K 1 Reply Last reply 20 May 2021, 14:17
          0
          • K kshegunov
            20 May 2021, 13:54

            @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.

            G Offline
            G Offline
            Gunkut
            wrote on 20 May 2021, 14:15 last edited by
            #5

            @kshegunov I think timer->start() does not accept any arguments. So using setInterval() fixed it. I couldn't catch that in docs though

            K 1 Reply Last reply 20 May 2021, 14:17
            0
            • G Gunkut
              20 May 2021, 14:15

              @kshegunov I think timer->start() does not accept any arguments. So using setInterval() fixed it. I couldn't catch that in docs though

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 20 May 2021, 14:17 last edited by
              #6

              @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.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • G Gunkut
                20 May 2021, 14:11

                @artwaw yeah that solved the issue. That was not mentioned in docs. Thanks.

                K Offline
                K Offline
                KroMignon
                wrote on 20 May 2021, 14:17 last edited by
                #7

                @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.

                It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                1 Reply Last reply
                1

                1/7

                20 May 2021, 13:27

                • Login

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