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. Qt Signal Slot
Qt 6.11 is out! See what's new in the release blog

Qt Signal Slot

Scheduled Pinned Locked Moved Solved General and Desktop
signal&slotqprocesspython
6 Posts 4 Posters 3.8k 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.
  • gizalpG Offline
    gizalpG Offline
    gizalp
    wrote on last edited by gizalp
    #1

    Hello everyone, I am very new at Qt C++ and trying to understand the logic of signal slot. What I wanted to implement is the following;
    -When user on click the button, the external pyhton code that I wanted to run will be run.

    I have seen this post --> http://www.qtforum.org/article/3773/when-pushbutton-click-qprocess-start.html?s=ddaff16695b9e225ee8a5f07c46f9e8d0f26d5df#post16206 .
    Here is my code part;

    public slots:
        void startProcess();
    
    signals:
        void clicked();
    
    
    connect(ui->button, SIGNAL(clicked()),this, SLOT(startProcess()));
    
    void MainWindow::startProcess(){
        QProcess process;
    
                process.setWorkingDirectory("home/giz/Documents");
                process.setProgram("python helloworld.py");
                process.start("python helloworld.py");
                process.waitForFinished(1000);
    }
    

    When I run the code I am getting the following error;

    QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
    

    Which one is wrong? My signal slot logic or qprocess usage?

    joeQJ J.HilkJ 2 Replies Last reply
    0
    • gizalpG gizalp

      Hello everyone, I am very new at Qt C++ and trying to understand the logic of signal slot. What I wanted to implement is the following;
      -When user on click the button, the external pyhton code that I wanted to run will be run.

      I have seen this post --> http://www.qtforum.org/article/3773/when-pushbutton-click-qprocess-start.html?s=ddaff16695b9e225ee8a5f07c46f9e8d0f26d5df#post16206 .
      Here is my code part;

      public slots:
          void startProcess();
      
      signals:
          void clicked();
      
      
      connect(ui->button, SIGNAL(clicked()),this, SLOT(startProcess()));
      
      void MainWindow::startProcess(){
          QProcess process;
      
                  process.setWorkingDirectory("home/giz/Documents");
                  process.setProgram("python helloworld.py");
                  process.start("python helloworld.py");
                  process.waitForFinished(1000);
      }
      

      When I run the code I am getting the following error;

      QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
      

      Which one is wrong? My signal slot logic or qprocess usage?

      joeQJ Offline
      joeQJ Offline
      joeQ
      wrote on last edited by joeQ
      #2

      @gizalp hi,welcome friend.

      connect(ui->button, &QPushButton::clicked,this, &MainWindow::startProcess);
      

      or

      connect(ui->button, SIGNAL(clicked()),this, SLOT(startProcess()));
      

      Just do it!

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mostefa
        wrote on last edited by
        #3

        Hi @gizalp

        Maybe somewhere on your code you have a slot named on_pushButton_clicked(), and this kind of name is used for QMetaObject::connectSlotsByName,

        If you have a slot with the name on_pushButton_clicked() , try just to rename it to onPushButtonClicked() !

        gizalpG 1 Reply Last reply
        5
        • gizalpG gizalp

          Hello everyone, I am very new at Qt C++ and trying to understand the logic of signal slot. What I wanted to implement is the following;
          -When user on click the button, the external pyhton code that I wanted to run will be run.

          I have seen this post --> http://www.qtforum.org/article/3773/when-pushbutton-click-qprocess-start.html?s=ddaff16695b9e225ee8a5f07c46f9e8d0f26d5df#post16206 .
          Here is my code part;

          public slots:
              void startProcess();
          
          signals:
              void clicked();
          
          
          connect(ui->button, SIGNAL(clicked()),this, SLOT(startProcess()));
          
          void MainWindow::startProcess(){
              QProcess process;
          
                      process.setWorkingDirectory("home/giz/Documents");
                      process.setProgram("python helloworld.py");
                      process.start("python helloworld.py");
                      process.waitForFinished(1000);
          }
          

          When I run the code I am getting the following error;

          QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
          

          Which one is wrong? My signal slot logic or qprocess usage?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @gizalp said in Qt Signal Slot:

          When I run the code I am getting the following error;
          QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()

          Which one is wrong? My signal slot logic or qprocess usage?

          seems like you created a pushbutton in QtDesigner, right cliked it and added Signal/Slot mechanismn that created a on_pushButton_clicked() function in your MainWindow class.
          You either went and renamed the button in the designer-form or deleted the function or something like that.

          However a clean rebuild should fix that for you


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          5
          • M mostefa

            Hi @gizalp

            Maybe somewhere on your code you have a slot named on_pushButton_clicked(), and this kind of name is used for QMetaObject::connectSlotsByName,

            If you have a slot with the name on_pushButton_clicked() , try just to rename it to onPushButtonClicked() !

            gizalpG Offline
            gizalpG Offline
            gizalp
            wrote on last edited by
            #5

            @mostefa Thanks, that fixed my problem!

            M 1 Reply Last reply
            0
            • gizalpG gizalp

              @mostefa Thanks, that fixed my problem!

              M Offline
              M Offline
              mostefa
              wrote on last edited by
              #6

              @gizalp said in Qt Signal Slot:

              @mostefa Thanks, that fixed my problem!

              You are welcome =)

              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