Connect not declared in this scope



  • Hi
    I was trying to record my voice using Qt but when i compiled the problem i get this error:
    connect was not declared in this scope .
    here's the code:
    @
    #include <QtGui/QApplication>
    #include "mainwindow.h"
    #include <QPushButton>
    #include <QVBoxLayout>
    #include <QHBoxLayout>
    #include <QTextEdit>
    #include <QWidget>
    #include <record.h>
    #include <QObject>

    int main(int argc, char argv[])
    {
    QApplication a(argc, argv);
    QWidget w;
    Record
    rec=new Record();
    //MainWindow w;
    QPushButton *record =new QPushButton("Record");
    QPushButton *stop =new QPushButton("Stop");
    QTextEdit *output=new QTextEdit() ;
    output->setGeometry(5, 5, 200, 150);
    QVBoxLayout *vlayout=new QVBoxLayout;
    QHBoxLayout *hlayout=new QHBoxLayout;
    QBoxLayout *layout=new QVBoxLayout;
    hlayout->addWidget(record);
    hlayout->addWidget(stop);
    vlayout->addLayout(hlayout);
    vlayout->addWidget(output);
    layout->addLayout(vlayout);
    w.setLayout(layout);
    connect(record,SIGNAL(clicked()),rec,SLOT(startRecord()));
    // connect(record,SIGNAL(clicked()),a,SLOT(quit()));

    w.show();
    
    return a.exec&#40;&#41;;
    

    }
    @

    How can i fix that .

    Thanks in advance .



  • connect is a static method of QObject therefore it is not in scope in your main. You should call this way: QObject::connect



  • try QObject::connect()
    also you need to pass pointer to connect like
    &a not a



  • @VCsala :thanks that resolve my problem , but what i didn't understand is i already test it.


Log in to reply
 

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