Error C3861 'pass' identifier not found [Beginer]



  • Hay all,

    First to thank you in advance for any provided help.
    This is my first post here, apologies for formatting mistakes or similar things.
    I'm trying to run simple turing machine in gui. I'm using Qt 5.4.0 (64 bit),
    and running on a Windows 8.1. My understanding is that it should work fine
    without further configuration, although I have some doubts. Previous programs that
    I created, in previous version of Qt(4.x.x), worked fine configured similarly to this.
    Problem is in creation of signal from one thread to main program.
    I get this error:

    @error: C3861: 'pass' identifier not found@

    commenting this section in threads cpp causes program to compile successfully:

    emit pass(a, b, count);
    

    this is the function in which emit is located from turingmcn.cpp:

    @void Turing_run(Turing *mcn, char *tape, int tape_len)
    {
    int count=0;
    if (!mcn->current)
    printf_s("Turning machine has now start state.");
    while (TRUE)
    {
    if(choice == 0)
    {
    if (mcn->current->accept == TRUE)
    {
    a=mcn->current->accept;
    b=mcn->current->id;
    break;
    }
    else if (mcn->current->reject == TRUE)
    {
    a=mcn->current->accept;
    b=mcn->current->id;
    break;
    }
    else
    {
    Turing_step(mcn, tape, tape_len);
    count++;
    printf_s("current state: %d\n", mcn->current->id);
    }
    }
    else if (choice == 1)
    {
    Turing_step(mcn, tape, tape_len);
    count++;
    }
    else
    {
    while(choice==3)
    {
    SleepConditionVariableCS(&paused,&wait,INFINITE);
    }
    if(choice == 4)
    {
    mcn->current->id=0;
    }
    }
    }
    emit pass(a, b, count);
    }@

    this is header of a thread turingmcn.h

    @#ifndef TURINGMCN
    #define TURINGMCN
    #include <QtCore>
    #include <QThread>
    #include "string"

    Q_DECLARE_METATYPE (std::string)
    class turing: public QThread
    {
    Q_OBJECT
    public:
    explicit turing(QObject *parent = 0);

    public slots:
    void sentence(QString);
    void button(int);

    signals:
    void pass(int, int, int);

    };@

    #endif // TURINGMCN

    This is part of main cpp file:

    @TuringMachine::TuringMachine(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::TuringMachine)
    {
    ui->setupUi(this);
    T = new turing(this);
    ui->label_5->hide();
    connect(this, SIGNAL(sentence(QString)), T, SLOT(sentence(QString)));
    connect(this, SIGNAL(button(int)), T, SLOT(button(int)));
    connect(T, SIGNAL(pass(int, int, int)), this, SLOT(part(int,int,int)));

    }@

    And his header:
    @#ifndef TURINGMACHINE_H
    #define TURINGMACHINE_H

    #include "turingmcn.h"
    #include "string"
    #include <QMainWindow>
    #include <QtCore>

    namespace Ui {
    class TuringMachine;
    }

    class TuringMachine : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit TuringMachine(QWidget *parent = 0);
    ~TuringMachine();
    turing *T;

    signals:
    void sentence(QString);
    void button(int);

    public slots:
    void part(int, int, int);

    private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();
    
    void on_lineEdit_editingFinished();
    
    void on_pushButton_4_clicked();
    

    void on_pushButton_3_clicked();

    private:
    Ui::TuringMachine *ui;

    };

    #endif // TURINGMACHINE_H@

    I apriciate any kind of help. Tnx again.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Turing_run is not a function of your turing class thus pass is unknown.

    Did you meant to reimplement QThread's run function ?



  • First of thank you for your reply.
    Yes, kind of. I have another function that defines what is Turing* mcn, its states and transitions. I wanted to run Turing_run when the button is pressed. But I don't know how to pass parameters from other function if Turing_run is slot. And if Turing_run is not slot I don't know how to run it on event in mainwindow.cpp (main thread).
    I apologize if my english grammar I'm not very good in english.


  • Lifetime Qt Champion

    A slot is a member function that you can also call like a normal function with parameters.

    Can you show with e.g. pseudo code how you would like to make it work ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.