Results 1 to 2 of 2

Thread: undefined reference to ...(loadfile)

  1. #1
    Join Date
    Jun 2014
    Posts
    47
    Thanks
    6
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default undefined reference to ...(loadfile)

    hi to all, i've centos 6.6 in VM and Qt 5.2. i am building a small project having this problem

    Qt Code:
    1. /opt/projects/Qt/find/spreadsheetmainwindow.cpp:52: error: undefined reference to `SpreadSheetMainWindow::loadFile(QString const&)'
    To copy to clipboard, switch view to plain text mode 
    even i have declared in header file(spreadsheetmainwindow.h)
    Qt Code:
    1. void SpreadSheetMainWindow::open()
    2. {
    3. if(okToContinue())
    4. {
    5. QString fileName = QFileDialog::getOpenFileName(this, "OPEN SP FILES", ".",
    6. "SpreadSheet Files (*.sp)");
    7. if(!fileName.isEmpty())
    8. loadFile(fileName);//here is error
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 
    and not only for this loadFile(filename) function but for most of functions declared in header file.
    as in :-
    Qt Code:
    1. undefined reference to `SpreadSheetMainWindow::setFormula(int, int, QString const&)'
    To copy to clipboard, switch view to plain text mode 
    header file is :-

    Qt Code:
    1. #ifndef SPREADSHEETMAINWINDOW_H
    2. #define SPREADSHEETMAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include <QTableWidget>
    6. #include <QLabel>
    7. #include <QMessageBox>
    8. #include <QFileDialog>
    9. #include <QCloseEvent>
    10. #include <QClipboard>
    11. #include <QObject>
    12. #include <QLineEdit>
    13. #include <QDataStream>
    14. #include <QFile>
    15. #include <QTableWidgetSelectionRange>
    16.  
    17. #include "sortdialog.h"
    18. #include "gotocelldialog.h"
    19. #include "finddialog.h"
    20. #include "cell.h"
    21.  
    22. namespace Ui {
    23. class SpreadSheetMainWindow;
    24. }
    25.  
    26. class Cell;
    27. class SpreadsheetCompare;
    28. class gotoCellDialog;
    29.  
    30. class SpreadSheetMainWindow : public QMainWindow//, public QTableWidget
    31. {
    32. Q_OBJECT
    33.  
    34. public:
    35. bool autoRecalculate() const { return autoRecalc; }
    36. QString currentLocation() const;
    37. QString currentFormula() const;
    38. QTableWidgetSelectionRange selectedRange() const;
    39. void clear();
    40. bool readFile(const QString &fileName);
    41. bool writeFile(const QString &fileName);
    42. void sort(const SpreadsheetCompare &compare);
    43.  
    44.  
    45. public:
    46. explicit SpreadSheetMainWindow(QWidget *parent = 0);
    47. ~SpreadSheetMainWindow();
    48. void ConnectActions();
    49.  
    50. protected:
    51. void closeEvent(QCloseEvent *event);
    52.  
    53. private slots:
    54. void newFile();
    55. void open();
    56. bool save();
    57. bool saveAs();
    58. void find();
    59. void goToCell();
    60. void sort();
    61. void about();
    62. void openRecentFile();
    63. void updateStatusBar();
    64. void spreadsheetModified();
    65.  
    66. signals:
    67.  
    68. void modified();
    69.  
    70. private slots:
    71. void somethingChanged();
    72. public slots:
    73. void cut();
    74. void copy();
    75. void paste();
    76. void del();
    77. void selectCurrentRow();
    78. void selectCurrentColumn();
    79. void recalculate();
    80. void setAutoRecalculate(bool recalc);
    81. void findNext(const QString &str, Qt::CaseSensitivity cs);
    82. void findPrevious(const QString &str, Qt::CaseSensitivity cs);
    83.  
    84.  
    85. private:
    86. enum { MagicNumber = 0x7F51C883, RowCount = 999, ColumnCount = 26 };
    87.  
    88. Cell *cell(int row, int column) const;
    89. QString text(int row, int column) const;
    90. QString formula(int row, int column) const;
    91. void setFormula(int row, int column, const QString &formula);
    92.  
    93. bool autoRecalc;
    94.  
    95. void configureStatusBar();
    96.  
    97. private:
    98. Ui::SpreadSheetMainWindow *ui;
    99. QLabel *labellocation;
    100. QLabel *labelformula;
    101. gotoCellDialog *dialog;
    102.  
    103. private:
    104. void createContextMenu();
    105. void readSettings();
    106. void writeSettings();
    107.  
    108. bool okToContinue();
    109. bool loadFile(const QString &fileName);
    110. bool saveFile(const QString &fileName);
    111. void setCurrentFile(const QString &fileName);
    112. void updateRecentFileActions();
    113. QString strippedName(const QString &fullFileName);
    114.  
    115. // Spreadsheet *spreadsheet;
    116. FindDialog *findDialog;
    117. QLabel *locationLabel;
    118. QLabel *formulaLabel;
    119. QStringList recentFiles;
    120. QString curFile;
    121. enum { MaxRecentFiles = 5 };
    122. QAction *recentFileActions[MaxRecentFiles];
    123. QAction *separatorAction;
    124. QTableWidget *tablewidget;
    125. };
    126.  
    127. class SpreadsheetCompare
    128. {
    129. public:
    130. bool operator()(const QStringList &row1,
    131. const QStringList &row2) const;
    132.  
    133. enum { KeyCount = 3 };
    134. int keys[KeyCount];
    135. bool ascending[KeyCount];
    136. };
    To copy to clipboard, switch view to plain text mode 

    please suggest me how t recover this " undefined reference " problem.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: undefined reference to ...(loadfile)

    Hi, did you implement loadFile() somewhere? The header file only tells the compiler that the function will be available during the linking stage, so you need to implement it to get rid of the "undefined reference".

    Ginsengelf

Similar Threads

  1. undefined reference
    By deepakswaroop in forum Newbie
    Replies: 1
    Last Post: 2nd March 2011, 07:46
  2. undefined reference
    By digidas in forum Newbie
    Replies: 9
    Last Post: 19th May 2010, 14:04
  3. undefined reference
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2009, 14:45
  4. Undefined Reference To...
    By ManuMies in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2009, 13:14
  5. Undefined reference
    By Salazaar in forum Newbie
    Replies: 12
    Last Post: 23rd May 2007, 11:21

Tags for this Thread

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.