Getting "undefined reference" in QT Creator when calling a specific function

So I am reading this book: C ++ GUI Programming with Qt 4, Second Edition by Jasmin Blanchette; Mark Summerfield to learn GUI programming. And following the instructions in the book to create a simple spreadsheet application, I get an "undefined" link, an error when I try to compile the Spreadsheet widget.

All errors seem to come from the function Cell *Spreadsheet::cell(int row, int column)


Cell *Spreadsheet::cell(int row, int column) const
    return static_cast<Cell *>(item(row, column));


This is the first function that complains about spreadsheet.cpp

QString Spreadsheet::formula(int row, int column) const {
    Cell *c = cell(row, column);
    if (c) {
        return c->formula();
    } else {
        return "";


If the string Cell *c = cell(row, column);

Sends an error: /home/axel/QtSDK/Code/Spreadsheet/spreadsheet.cpp: -1: error: undefined reference to `Cell :: Cell () '

This happens wherever it is called cell(row, column)

. The function itself is defined in the distribution header in the private section as:Cell *cell(int row, int column) const;

Sorry if this seems messy, I am new to C ++ programming.

Here's my .pro file

CONFIG += console
CONFIG += qt

SOURCES += main.cpp \



If I am missing something, I will add it as soon as I can.

Thanks, Axel


source to share

1 answer

There is Cell

no class definition . It should be cell.h

at least, and it should be included in the spreadsheet.cpp file, or its code could be directly included in, spresheed.h

or .cpp

less likely. In any case, the error means there is no constructor Cell




All Articles