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

    artwawA 1 Reply Last reply
    0
    • G Gunkut

      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.

      artwawA Offline
      artwawA Offline
      artwaw
      wrote on 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

      kshegunovK 1 Reply Last reply
      0
      • artwawA artwaw

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

        timer->setInterval(100);
        timer->start();
        
        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on 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
        1
        • G Offline
          G Offline
          Gunkut
          wrote on last edited by
          #4

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

          KroMignonK 1 Reply Last reply
          0
          • kshegunovK kshegunov

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

            kshegunovK 1 Reply Last reply
            0
            • G Gunkut

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

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on 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

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

                KroMignonK Offline
                KroMignonK Offline
                KroMignon
                wrote on 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

                • Login

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