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. Object::connect: No such signal issue
Forum Updated to NodeBB v4.3 + New Features

Object::connect: No such signal issue

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 5.8k Views 1 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.
  • mat007M Offline
    mat007M Offline
    mat007
    wrote on last edited by
    #1

    Hi,
    I create new signals and slots and when i run my program i have this error, but check it and everthing looks ok.
    @
    Object::connect: No such signal MainWindow::hotovo(vector<string> data) in mainwindow.cpp:15
    Object::connect: (sender name: 'MainWindow')
    Object::connect: (receiver name: 'Dialog')@

    mainwindow.h
    @#include <QMainWindow>
    #include "dialog.h"

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:

    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    std::vectorstd::string cestaTabulky;
    std::vectorstd::string jmenaTabulky;
    std::vectorstd::string data2;
    std::vector<int> pocty;
    protected slots:
    void naplnit_comboBox();
    signals:
    void hotovo(std::vectorstd::string data);
    private slots:
    void on_pridatBttn_clicked();
    void on_comboBox_currentIndexChanged(int index);

    private:
    Ui::MainWindow *ui;
    Dialog *pridani;

    };@

    mainwindow.cpp

    @MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    pridani = new Dialog(this);
    connect(pridani,SIGNAL(created()),this,SLOT(naplnit_comboBox())); connect(this,SIGNAL(hotovo(vector<string>data)),pridani,SLOT(naplnit_comboBox2(vector<string> data) ) );

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_pridatBttn_clicked()
    {

    pridani->show();
    }

    void MainWindow::naplnit_comboBox()
    {

    emit hotovo(jmenaTabulky);
    

    }

    void MainWindow::on_comboBox_currentIndexChanged(int index)
    {
    QStandardItemModel model = qobject_cast<QStandardItemModel>(ui->tableView->model());
    int radek = 0;
    int sloupec = 7;

       int pocetRadku  = data2.size()/5;
       //if (index != 0) index-- ;
    

    ui->tableView->updatesEnabled();
    for (radek = 0; radek < pocetRadku;radek++)
    {

               QStandardItem *item =  model->item(radek,sloupec);
               QString data = item->accessibleText();
               if(jmenaTabulky[index].compare(data.toStdString()) == 0)
                   {
                       ui->tableView->setColumnHidden(radek,false);
                   }
                       else
                   {
                       ui->tableView->setColumnHidden(radek,true);
                   }
    
        }
    

    }

    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Do you have any warnings from a compiler?

      From you code I don't see that you have
      @
      #include <vector>
      #include <string>
      //... etc
      @
      Is it included in "dialog.h"

      One more thing.
      Do you use vector from STL?
      You did not put std:: in front of vector and string in the signal declaration.
      But you did it few lines above.

      1 Reply Last reply
      0
      • mat007M Offline
        mat007M Offline
        mat007
        wrote on last edited by
        #3

        [quote author="andreyc" date="1401297592"]Do you have any warnings from a compiler?

        From you code I don't see that you have
        @
        #include <vector>
        #include <string>
        //... etc
        @
        Is it included in "dialog.h"

        One more thing.
        Do you use vector from STL?
        You did not put std:: in front of vector and string in the signal declaration.
        But you did it few lines above.
        [/quote]
        yes, i it is. i correct namespace in hotovo and it havent effect on it.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          Do you have the same error ?
          @
          Object::connect: No such signal MainWindow::hotovo(vector<string> data) in mainwindow.cpp:15
          @

          1 Reply Last reply
          0
          • mat007M Offline
            mat007M Offline
            mat007
            wrote on last edited by
            #5

            [quote author="andreyc" date="1401298839"]Do you have the same error ?
            @
            Object::connect: No such signal MainWindow::hotovo(vector<string> data) in mainwindow.cpp:15
            @
            [/quote]

            yes

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andreyc
              wrote on last edited by
              #6

              Yep, I see. Created a project and got the same result.
              Try to use "new connect":http://qt-project.org/wiki/New_Signal_Slot_Syntax#b61c3e32c4a7548eb2a0ea5a505fd51b
              @
              connect(this, &MainWindow::hotovo, pridani, &Dialog::naplnit_comboBox2);
              @

              1 Reply Last reply
              0
              • mat007M Offline
                mat007M Offline
                mat007
                wrote on last edited by
                #7

                [quote author="andreyc" date="1401299367"]Yep, I see. Created a project and got the same result.
                Try to use "new connect":http://qt-project.org/wiki/New_Signal_Slot_Syntax#b61c3e32c4a7548eb2a0ea5a505fd51b
                @
                connect(this, &MainWindow::hotovo, pridani, &Dialog::naplnit_comboBox2);
                @[/quote]

                no it doesnt work i use Qt 4.8.1

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andreyc
                  wrote on last edited by
                  #8

                  As a workaround you may try to use QVector<QString>

                  1 Reply Last reply
                  0
                  • jeremy_kJ Offline
                    jeremy_kJ Offline
                    jeremy_k
                    wrote on last edited by
                    #9

                    Are you certain that the signature of the signal and slot match? I put together this example that has a signal and slot which use std::vector.

                    @
                    #include <QCoreApplication>
                    #include <QMetaEnum>
                    #include <QDebug>

                    #include <cstdio>
                    #include <vector>

                    class Object : public QObject
                    {
                    Q_OBJECT
                    public:
                    Object() : QObject() {}

                    public slots:
                    void mySlot(std::vector<int> param)
                    {
                    qDebug() << "This is" << PRETTY_FUNCTION << "with" << param.front();
                    }

                    signals:
                    void mySignal(std::vector<int> param);
                    };

                    int main(int argc, char *argv[])
                    {
                    QCoreApplication a(argc, argv);

                    Object obj;
                    const QMetaObject *meta = obj.metaObject();
                    qDebug() << "walking meta-Object" <&lt; meta;
                    for (int i = 0; i &lt; meta->methodCount(); i++) {
                        QMetaMethod method = meta->method(i);
                        qDebug() << "method:" << method.methodSignature().data();
                    }
                    obj.connect(&obj, SIGNAL(mySignal(std::vector<int>)), &obj, SLOT(mySlot(std::vector<int>)));
                    std::vector<int> vec(1);
                    vec[0] = 12345;
                    emit obj.mySignal(vec);
                    return 0;
                    

                    }

                    #include "main.moc"
                    @

                    Asking a question about code? http://eel.is/iso-c++/testcase/

                    1 Reply Last reply
                    0
                    • jeremy_kJ Offline
                      jeremy_kJ Offline
                      jeremy_k
                      wrote on last edited by
                      #10

                      Having taken a closer look at the code, I think the problem is the use of the SIGNAL macro, which specifies a parameter of "vector" instead of "std::vector".

                      The old-style connect() is string driven, using the declaraction of the signal and slot, and the parameters to SIGNAL() and SLOT(). It doesn't know that vector is a std::vector if preceeded by using namespace std.

                      Asking a question about code? http://eel.is/iso-c++/testcase/

                      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