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. Resiving signal from qml

Resiving signal from qml

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.5k 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.
  • M Offline
    M Offline
    mehrdad
    wrote on last edited by
    #1

    i want to receive a string from my qml file...all that i do is copying this two codes from sub url in my program and including libraries...
    "this link!!!":http://qt-project.org/doc/qt-4.8/qtbinding.html#receiving-signals
    but this error occur...
    undefined refrence to 'Vtable fo My class'

    i think its because cpp code line 13-in addressing qml file...
    @// MyItem.qml
    import QtQuick 1.0

    Item {
    id: item
    width: 100; height: 100

     signal qmlSignal(string msg)
    
     MouseArea {
         anchors.fill: parent
         onClicked: item.qmlSignal("Hello from QML")
     }
    

    }
    @
    @class MyClass : public QObject
    {
    Q_OBJECT
    public slots:
    void cppSlot(const QString &msg) {
    qDebug() << "Called the C++ slot with message:" << msg;
    }
    };

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

     QDeclarativeView view(QUrl::fromLocalFile&#40;"MyItem.qml"&#41;);
     QObject *item = view.rootObject();
    
     MyClass myClass;
     QObject::connect(item, SIGNAL(qmlSignal(QString)),
                      &myClass, SLOT(cppSlot(QString)));
    
     view.show();
     return app.exec();
    

    }@

    and this is my comple output

    22:00:15: Running build steps for project untitled5...
    22:00:15: Configuration unchanged, skipping qmake step.
    22:00:15: Starting: "C:\Qt\qtcreator-2.4.0\mingw\bin\mingw32-make.exe"
    C:/Qt/qtcreator-2.4.0/mingw/bin/mingw32-make.exe -f Makefile.Debug
    mingw32-make.exe[1]: Entering directory C:/Qt/qtcreator-2.4.0/untitled5-build-desktop-Qt_4_8_0__4_8_0__Debug' g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DECLARATIVE_DEBUG -DQT_DLL -DQT_DECLARATIVE_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\4.8.0\include\QtCore" -I"..\..\4.8.0\include\QtGui" -I"..\..\4.8.0\include\QtDeclarative" -I"..\..\4.8.0\include" -I"..\untitled5\qmlapplicationviewer" -I"..\..\4.8.0\include\ActiveQt" -I"debug" -I"..\untitled5" -I"." -I"..\..\4.8.0\mkspecs\win32-g++" -o debug\main.o ..\untitled5\main.cpp g++ -mthreads -Wl,-subsystem,windows -o debug\untitled5.exe debug/main.o debug/qmlapplicationviewer.o debug/moc_qmlapplicationviewer.o -L"c:\Qt\4.8.0\lib" -lmingw32 -lqtmaind -lQtDeclaratived4 -lQtGuid4 -lQtCored4 mingw32-make.exe[1]: Leaving directory C:/Qt/qtcreator-2.4.0/untitled5-build-desktop-Qt_4_8_0__4_8_0__Debug'
    debug/main.o: In function MyClass': C:\Qt\qtcreator-2.4.0\untitled5-build-desktop-Qt_4_8_0__4_8_0__Debug/../untitled5/main.cpp:5: undefined reference to vtable for MyClass'
    debug/main.o: In function ~MyClass': C:\Qt\qtcreator-2.4.0\untitled5-build-desktop-Qt_4_8_0__4_8_0__Debug/../untitled5/main.cpp:5: undefined reference to vtable for MyClass'
    collect2: ld returned 1 exit status
    mingw32-make.exe[1]: *** [debug\untitled5.exe] Error 1
    mingw32-make.exe: *** [debug] Error 2
    22:00:17: The process "C:\Qt\qtcreator-2.4.0\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project untitled5 (target: Desktop)
    When executing build step 'Make'

    i cant fix it!
    help????please?????

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gimble
      wrote on last edited by
      #2

      See this thread:
      http://qt-project.org/forums/viewthread/6084

      You'll find it extremely similar and helpful.

      I found it by Googling "undefined reference to `vtable for MyClass’"

      Google == friend

      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