r/cpp•
[deleted]

Homework Help

I'm trying to compile a program that's going over Qt's Signals and Slots and can't get my main.cpp file to compile. I know it has something to do with a mis-matched signature, but I haven't been able to figure out how to get the signature on my instantiation to match up with the object's constructor. Please help.

Here's my main.cpp file:


#include <QCoreApplication>
#include <QTimer>

#include <iostream>

#include "name_model.h"
#include "name_controller.h"
#include "name_first_view.h"
#include "name_last_view.h"

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

    QCoreApplication app(argc, argv);

    NameModel model();
    NameController controller();

    FirstView first_view(model, app);
    LastView last_view(model, app);

    QObject::connect(&model, SIGNAL(nameChanged()), &first_view, SLOT(updateView()));
    QObject::connect(&model, SIGNAL(nameChanged()), &last_view, SLOT(updateView()));
    QObject::connect(&controller, SIGNAL(quit()), &app, SLOT(quit()));

    QTimer timer;
    timer.start(0);
    QObject::connect(&timer, SIGNAL(timeout()), &controller, getName());

    std::cerr << "starting event loop..." << std::endl;

    int return_value = app.exec();

    std::cerr << "done processing event loop." << std::endl;

    std::cout << endl;

    return return_value;

}

And here's the error I'm getting

[ 8%] Building CXX object CMakeFiles/MVC_practicum.dir/main.o
u/zon-d2/ugrad/pjsa224/pract-9/source/main.cpp: In function âint main(int, char**)â:
u/zon-d2/ugrad/pjsa224/pract-9/source/main.cpp:18: error: no matching function for call to âFirstView::FirstView(NameModel (&)(), QCoreApplication&)â
u/zon-d2/ugrad/pjsa224/pract-9/source/name_first_view.h:14: note: candidates are: FirstView::FirstView(NameModel*, QObject*)
u/zon-d2/ugrad/pjsa224/pract-9/source/name_first_view.h:13: note: FirstView::FirstView()
u/zon-d2/ugrad/pjsa224/pract-9/source/name_first_view.h:10: note: FirstView::FirstView(const FirstView&)
u/zon-d2/ugrad/pjsa224/pract-9/source/main.cpp:19: error: no matching function for call to âLastView::LastView(NameModel (&)(), QCoreApplication&)â
u/zon-d2/ugrad/pjsa224/pract-9/source/name_last_view.h:14: note: candidates are: LastView::LastView(NameModel*, QObject*)
u/zon-d2/ugrad/pjsa224/pract-9/source/name_last_view.h:13: note: LastView::LastView()
u/zon-d2/ugrad/pjsa224/pract-9/source/name_last_view.h:10: note: LastView::LastView(const LastView&)
u/zon-d2/ugrad/pjsa224/pract-9/source/main.cpp:21: error: no matching function for call to âQObject::connect(NameModel ()(), const char, FirstView*, const char*)â
/usr/include/qt4/QtCore/qobject.h:198: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/usr/include/qt4/QtCore/qobject.h:313: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
u/zon-d2/ugrad/pjsa224/pract-9/source/main.cpp:22: error: no matching function for call to âQObject::connect(NameModel ()(), const char, LastView*, const char*)â
/usr/include/qt4/QtCore/qobject.h:198: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/usr/include/qt4/QtCore/qobject.h:313: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
u/zon-d2/ugrad/pjsa224/pract-9/source/main.cpp:23: error: no matching function for call to âQObject::connect(NameController ()(), const char, QCoreApplication*, const char*)â
/usr/include/qt4/QtCore/qobject.h:198: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/usr/include/qt4/QtCore/qobject.h:313: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
u/zon-d2/ugrad/pjsa224/pract-9/source/main.cpp:27: error: âgetNameâ was not declared in this scope
u/zon-d2/ugrad/pjsa224/pract-9/source/main.cpp:35: error: âendlâ was not declared in this scope
make[2]: *** [CMakeFiles/MVC_practicum.dir/main.o] Error 1
make[1]: *** [CMakeFiles/MVC_practicum.dir/all] Error 2
make: *** [all] Error 2

Posted Mar 24, 2012, 11:50 PM UTC

01
Loading comments…