Results 1 to 5 of 5

Thread: About QUiLoader, Connect, Q_Object and 'undefined reference to `vtable for wrun' '

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default About QUiLoader, Connect, Q_Object and 'undefined reference to `vtable for wrun' '

    I want to have a simple ui loader and the posibility to connect signals from ui to slots stored in MyClass. (wrun)

    For example, I would can connect them with this code .
    Qt Code:
    1. QList<QPushButton *> pbto = formWidget->findChildren<QPushButton *>();
    2. for (int i=0;i<pbto.count();i++)
    3. {
    4. connect(pbto.at(i), SIGNAL(clicked()), this, SLOT(button_click));
    5. }
    To copy to clipboard, switch view to plain text mode 

    To do this :
    1.- I have to use Q_Object macro
    2.- I have to subclass Qobject

    When I compile I have get errors : 'undefined reference to `vtable for wrun' ' at the lines (in cpp) where is placed :
    wrun.cpp:11: undefined reference to `vtable for wrun'
    wrun.cpp:11: undefined reference to `vtable for wrun'
    debug/wrun.o: In function `~wrun':
    wrun.cpp:13: undefined reference to `vtable for wrun'
    wrun.cpp:13: undefined reference to `vtable for wrun'
    wrun.cpp:13: undefined reference to `vtable for wrun'

    Can anyone help me ?

    wrun.h
    Qt Code:
    1. class wrun : public QObject
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. wrun();
    7. ~wrun();
    8. ....
    To copy to clipboard, switch view to plain text mode 

    wrun.cpp
    Qt Code:
    1. #include "wrun.h"
    2. #include <QUiLoader>
    3.  
    4. wrun::wrun(){}
    5.  
    6. wrun::~wrun(){}
    7. ....
    To copy to clipboard, switch view to plain text mode 




    Any idea ?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: About QUiLoader, Connect, Q_Object and 'undefined reference to `vtable for wrun'

    rerun qmake since you probably included the Q_OBJECT macro later.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: About QUiLoader, Connect, Q_Object and 'undefined reference to `vtable for wrun'

    For later: your connect should probably be:
    Qt Code:
    1. connect(pbto.at(i), SIGNAL(clicked()), this, SLOT(button_click()));
    To copy to clipboard, switch view to plain text mode 
    Note the extra parentheses.

  4. #4
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: About QUiLoader, Connect, Q_Object and 'undefined reference to `vtable for wrun'

    Thanks
    Yes ! As simple as rebuild .... (and I already knew I had and extra parenthesis)

    This kind of things are those that perplex me
    Althought is another question but... anyone can indicate me a link about make, cmake, qmake, etc ?
    (really I dont understand nothing about it, by the moment QT are doing all for me but I dont understand what's happen when compile)

  5. #5
    Join Date
    May 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: About QUiLoader, Connect, Q_Object and 'undefined reference to `vtable for wrun'

    cmake has a good basic tutorial on it's website. Also if you google compiling Qt with cmake I found a really useful tutorial. I used it in part to get my cmake file.

    My CMakeLists.txt:
    Qt Code:
    1. cmake_minimum_required(VERSION 2.8)
    2.  
    3. PROJECT(MarkTracker)
    4.  
    5. FILE(GLOB MarkTracker_SOURCES *.cpp)
    6. FILE(GLOB MarkTracker_HEADERS *.hpp)
    7.  
    8. FILE(GLOB MarkTracker_UI *.ui)
    9.  
    10. configure_file ("${PROJECT_SOURCE_DIR}/info.h.in" "${PROJECT_BINARY_DIR}/info.h") # Makes info.h which has some marcos in it.
    11.  
    12. FIND_PACKAGE(Qt4 REQUIRED)
    13. SET(QT_USE_QTUITOOLS TRUE) # QtUiTools is for dynamic form loading
    14. INCLUDE(${QT_USE_FILE}) # Include the files Qt needs
    15. ADD_DEFINITIONS(${QT_DEFINITIONS}) # Define the things Qt needs defined
    16.  
    17. QT4_WRAP_UI(MarkTracker_UI_HEADERS ${MarkTracker_UI}) # Genertate ui_*.h files from .ui files
    18. QT4_WRAP_CPP(MarkTracker_HEADERS_MOC ${MarkTracker_HEADERS}) # Send our headers through the moc
    19.  
    20. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
    21. ADD_EXECUTABLE(marktracker
    22. ${MarkTracker_SOURCES}
    23. ${MarkTracker_HEADERS_MOC}
    24. ${MarkTracker_UI_HEADERS}
    25. )
    26. TARGET_LINK_LIBRARIES(marktracker ${QT_LIBRARIES})
    27. FILE(COPY resources DESTINATION .) # Get our resources file location
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. undefined reference to `QUiLoader::QUiLoader(QObject*)'
    By ashukla in forum Qt Programming
    Replies: 7
    Last Post: 7th October 2011, 19:05
  2. Qt Undefined Reference to vtable
    By ctote in forum Qt Programming
    Replies: 18
    Last Post: 24th February 2010, 23:24
  3. Undefined reference to 'vtable for XXX'
    By Sheng in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2008, 16:59
  4. undefined reference to vtable
    By renjithmamman in forum Qt Programming
    Replies: 5
    Last Post: 2nd July 2006, 05:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.