QtCreator problem?

Dirk Hohndel dirk at hohndel.org
Tue Jan 26 07:23:49 PST 2016


On Tue, Jan 26, 2016 at 04:16:05PM +0200, Willem Ferguson wrote:
> I am working with the subsurface project loaded into QtCreator. I created a
> new class, the files (.cpp, .h) of which exists in the directory:
> desktop-widgets.

The name downloadmanager.cpp could indicate a number of different things -
I know that you were planning to create the model for dive computer
vendors and models separately; that should go into qt-models.
desktop-widgets should only contain code that's exclusively used in the
desktop app, similarly qt-mobile for Subsurface-mobile.
subsurface-core is intended for core functionality, qt-models for models,
etc.

> When I refer to this class from within the Subsurface C++
> code, I get an error: "Undefined reference" to the constructor and method of
> the new class. Obviously the new class is instantiated inside the Subsurface
> code.

As Sebastian pointed out, you need to make sure it's linked into your
application by adding it to the SUBSURFACE_INTERFACE variable in
desktop_widgets/CMakeLists.txt (assuming it is indeed part of the desktop
UI) - or the corresponding variables in the CMakeLists.txt file in the
correct directory.

> I notice two things:
> 
> a) Attached image shows QtCreator side bar with File system at the top and
> with the recognised classes below. As file manager, it sees the .cpp and .h
> files ("downloadmanager.cpp & downloadmanager.h) but the class does not
> appear in the class view panel below.
> 
> b) If I look in the Subsurface.cbp file, the new class has also not been
> added there after QtCreator initially created the .cbp file.

That should both be fixed after you add it to the correct CMakeLists.txt
file (you may have to manually run cmake inside QtCreator to make it pick
up the new classes - you can do this on the Projects screen.

> I am convinced this is something basic and simple that I have not managed to
> understand.

I trip over this every single time I add a file. I'm not joking. Every
time.

/D


More information about the subsurface mailing list