Note that there are some explanatory texts on larger screens.

plurals
  1. POLNK Errors in Qt when trying to inherit?
    primarykey
    data
    text
    <p>I'm attempting to call a method from another class Bookmarks, however I keep getting LNK errors when I build my program and I don't understand why.</p> <pre><code>mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: class QStringList __cdecl Bookmarks::getList(void)" (?getList@Bookmarks@@QEAA?AVQStringList@@XZ) referenced in function "private: void __cdecl MainWindow::on_save_book_clicked(void)" (?on_save_book_clicked@MainWindow@@AEAAXXZ) debug\WebBrowser.exe:-1: error: LNK1120: 1 unresolved externals </code></pre> <p>Of course, the second error exists because of the first one, at least that much I know.</p> <p>I've declared my headers, including the class I want to use:</p> <pre><code>#include "mainwindow.h" #include "ui_mainwindow.h" #include "bookmarks.h" </code></pre> <p>And this is the slot I'm trying to use:</p> <pre><code>void MainWindow::on_save_book_clicked() { Bookmarks *bm = new Bookmarks(); QStringList book = bm -&gt; getList(); QFileDialog *fd = new QFileDialog; QString fileName = fd -&gt; getSaveFileName(this, tr("Save Bookmarks"), "", tr("Bookmarks (*.txt);;AllFiles (*)")); if (fileName.isEmpty()) { return; } else { QFile file(fileName); if (!file.open(QIODevice::WriteOnly)) { QMessageBox::information(this, tr("Unable to open file"), file.errorString()); } return; QDataStream out(&amp;file); out.setVersion(QDataStream::Qt_4_5); out &lt;&lt; bm; } } </code></pre> <p>I've determined that the error is coming from the line:</p> <pre><code>QStringList book = bm -&gt; getList(); </code></pre> <p>When I comment it out, I no longer get the link error, though I haven't a clue what problem it's causing. Why is this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload