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. void MainWindow::MakineStatR(int realStat) { QTimer::singleShot(150, this, SLOT(MakineStatR1));}
Forum Updated to NodeBB v4.3 + New Features

void MainWindow::MakineStatR(int realStat) { QTimer::singleShot(150, this, SLOT(MakineStatR1));}

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 2.8k Views 3 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.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by
    #1

    {ubuntu 14.04 Qt5.6} In my main I have these fun:

    I use directly in

    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    

    some other QTimer::singleshot with succes (there is not a "classic" QOBJECT related issue.... )

    but in other sub-fun ... example:

    void MainWindow::MakineStatR(int realStat) { QTimer::singleShot(150, this, SLOT(MakineStatR1));}
    void MainWindow::MakineStatR1() { emit sendInOutMachine(45); }
    

    not work at all and return these error:

    QObject::connect: Parentheses expected, slot MainWindow::MakineStatR1 in ...
    QObject::connect:  (receiver name: 'MainWindow')
    

    Why these??

    Regards
    Giorgio

    bkt

    p3c0P 1 Reply Last reply
    0
    • gfxxG gfxx

      {ubuntu 14.04 Qt5.6} In my main I have these fun:

      I use directly in

      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      

      some other QTimer::singleshot with succes (there is not a "classic" QOBJECT related issue.... )

      but in other sub-fun ... example:

      void MainWindow::MakineStatR(int realStat) { QTimer::singleShot(150, this, SLOT(MakineStatR1));}
      void MainWindow::MakineStatR1() { emit sendInOutMachine(45); }
      

      not work at all and return these error:

      QObject::connect: Parentheses expected, slot MainWindow::MakineStatR1 in ...
      QObject::connect:  (receiver name: 'MainWindow')
      

      Why these??

      Regards
      Giorgio

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @gfxx ,
      As exactly the error says you are missing the parentheses in here:
      { QTimer::singleShot(150, this, SLOT(MakineStatR1));}
      Should be
      { QTimer::singleShot(150, this, SLOT(MakineStatR1()));}

      Btw. you can use C++11 features to avoid the parentheses.

      QTimer::singleShot(150, this, &MainWindow::MakineStatR1)

      157

      1 Reply Last reply
      1
      • gfxxG Offline
        gfxxG Offline
        gfxx
        wrote on last edited by gfxx
        #3

        sorry.... an stupyd error during test ..... the error show me with the Parentheses is :

        QObject::connect: object not sxist ... or similar ... 
        
        

        (sorry now im out of office )
        referred to the fact that Void not exist in MaiWindows ..... but it exist .... and Q_OBJECT is declared in mainwindows.h....

        today i think can post the right error show

        regards
        giorgio

        bkt

        p3c0P 1 Reply Last reply
        0
        • gfxxG gfxx

          sorry.... an stupyd error during test ..... the error show me with the Parentheses is :

          QObject::connect: object not sxist ... or similar ... 
          
          

          (sorry now im out of office )
          referred to the fact that Void not exist in MaiWindows ..... but it exist .... and Q_OBJECT is declared in mainwindows.h....

          today i think can post the right error show

          regards
          giorgio

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @gfxx Alright, Post the exact error.

          157

          gfxxG 1 Reply Last reply
          0
          • p3c0P p3c0

            @gfxx Alright, Post the exact error.

            gfxxG Offline
            gfxxG Offline
            gfxx
            wrote on last edited by gfxx
            #5

            @p3c0 real code with problem

            void MainWindow::MakineStatR(int realStat) { QTimer::singleShot(150, this, SLOT(MakineStatR1(realStat)));}
            void MainWindow::MakineStatR1(int realS1) { emit sendInOutMachine(realS1); }
            

            real error ...

            QObject::connect: No such slot MainWindow::MakineStatR1(realStat) in ../KYC-C/mainwindow.cpp:1862
            QObject::connect:  (receiver name: 'MainWindow')
            thread5 command:   101
            

            yesterday i've test without passing int value to void..... it works..... with value passing i receive these error.....

            regards
            giorgio

            bkt

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @gfxx said:
              Hi
              The timeout() signal of QTimer do not take a parameter
              so
              void MainWindow::MakineStatR(int realStat) {
              QTimer::singleShot(150, this, SLOT(MakineStatR1(realStat)));
              }

              Is not possible as QTimer then would have to store your
              realStat and use that in its timeout(). If it had a paramter.

              So in short you cannot pass parameters that way as far as i know :)

              1 Reply Last reply
              1
              • Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #7

                realStat is a state. The timer will fire after some time (after you left the scope of realStat), so you need to preserve that state somewhere. You can use a lambda object for that:

                void MainWindow::MakineStatR(int realStat) {
                    QTimer::singleShot(150, [=]{ MakineStatR1(realStat); });
                }
                
                gfxxG 1 Reply Last reply
                2
                • Chris KawaC Chris Kawa

                  realStat is a state. The timer will fire after some time (after you left the scope of realStat), so you need to preserve that state somewhere. You can use a lambda object for that:

                  void MainWindow::MakineStatR(int realStat) {
                      QTimer::singleShot(150, [=]{ MakineStatR1(realStat); });
                  }
                  
                  gfxxG Offline
                  gfxxG Offline
                  gfxx
                  wrote on last edited by
                  #8

                  @Chris-Kawa said:

                  realStat is a state. The timer will fire after some time (after you left the scope of realStat), so you need to preserve that state somewhere. You can use a lambda object for that:

                  realStat is the number of modbus register that i call for cofirm after sending modbus command. after every sending command (from pusch button in gui) i control the execution via register. my gui is client modbus that control remote machine (server).
                  I need to send command from a void and request of machineStat from other one valid for all command and calling from pushbutton void.....

                  regards
                  giorgio

                  bkt

                  1 Reply Last reply
                  0

                  • Login

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