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. Connect not declared in this scope
QtWS25 Last Chance

Connect not declared in this scope

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 52.4k Views
  • 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.
  • N Offline
    N Offline
    Naouali
    wrote on last edited by
    #1

    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 .

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vcsala
      wrote on last edited by
      #2

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

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

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

        1 Reply Last reply
        0
        • N Offline
          N Offline
          Naouali
          wrote on last edited by
          #4

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

          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