QT lesson learned: linking in external classes
Posted by mholmes on 10 Mar 2010 in Activity log
Just spent an hour trying to get an app to compile using my MdhXmlEditor class. Although I was declaring the header file for the class in the header file for the main window, it couldn't find the class. Eventually I discovered that I had to manually add the header and cpp files for the two libraries I'm using to the QT .pro file, like this:
# ------------------------------------------------- # Project created by QtCreator 2010-03-10T14:41:22 # ------------------------------------------------- QT += xml \ xmlpatterns TARGET = createImtFiles TEMPLATE = app SOURCES += main.cpp \ mainwindow.cpp \ ../imagemarkuptool/trunk/projXmlEditor/mdhxmleditor.cpp \ ../imagemarkuptool/trunk/projXmlEditor/mdhxmlhighlighter.cpp HEADERS += mainwindow.h \ ../imagemarkuptool/trunk/projXmlEditor/mdhxmleditor.h \ ../imagemarkuptool/trunk/projXmlEditor/mdhxmlhighlighter.h FORMS +=
There's no equivalent of Delphi's "Add file to project", but obviously the pre-processor needs to know about this stuff; it can't rely on the compiler to find all the header files.