<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="default-style">
I have made a bare-bones version of my code and guess what: it won't link! I get messages:
</div>
<div class="default-style">
</div>
<div class="default-style">
/usr/src/dev/kde4/qtwitest/src/main.cpp:17: undefined reference to `vtable for QtwiTest'
</div>
<div class="default-style">
</div>
<div class="default-style">
This is usually caused by not supplying a constructor body, but I have done that. Can anyone see what is wrong?
</div>
<div class="default-style">
</div>
<div class="default-style">
<div class="default-style" style="padding-left: 40px;">
<span style="font-size: 8pt;">#include <QApplication></span>
<br><span style="font-size: 8pt;">#include <QMainWindow></span>
<br><span style="font-size: 8pt;">#include <QTreeWidget></span>
</div>
<div class="default-style" style="padding-left: 40px;">
<span style="font-size: 8pt;">#include <KXmlGuiWindow></span>
<br><span style="font-size: 8pt;">#include <KLocalizedString></span>
</div>
<div class="default-style" style="padding-left: 40px;">
<span style="font-size: 8pt;">class QtwiTest : public KXmlGuiWindow</span>
<br><span style="font-size: 8pt;">{</span>
<br><span style="font-size: 8pt;">Q_OBJECT </span>
<br><span style="font-size: 8pt;">public:</span>
<br><span style="font-size: 8pt;">QtwiTest();</span>
</div>
<div class="default-style" style="padding-left: 40px;">
<span style="font-size: 8pt;">virtual ~QtwiTest();</span>
<br><span style="font-size: 8pt;">};</span>
</div>
<div class="default-style" style="padding-left: 40px;">
<span style="font-size: 8pt;">QtwiTest::QtwiTest()</span>
<br><span style="font-size: 8pt;">{</span>
<br><span style="font-size: 8pt;">}</span>
</div>
<div class="default-style" style="padding-left: 40px;">
<span style="font-size: 8pt;">QtwiTest::~QtwiTest()</span>
<br><span style="font-size: 8pt;">{</span>
<br><span style="font-size: 8pt;">}</span>
</div>
<div class="default-style" style="padding-left: 40px;">
<br><span style="font-size: 8pt;">int main(int argc, char **argv)</span>
<br><span style="font-size: 8pt;">{</span>
<br><span style="font-size: 8pt;">QApplication app(argc, argv);</span>
<br><span style="font-size: 8pt;">KLocalizedString::setApplicationDomain("qtwi");</span>
</div>
<div class="default-style" style="padding-left: 40px;">
<span style="font-size: 8pt;">QtwiTest mv;</span>
<br><span style="font-size: 8pt;">QTreeWidget tw( &mv );</span>
<br><span style="font-size: 8pt;">QTreeWidgetItem twi( &tw );</span>
<br><span style="font-size: 8pt;">QBrush fb( Qt::red );</span>
<br>
<br><span style="font-size: 8pt;">mv.setCentralWidget( &tw );</span>
<br><span style="font-size: 8pt;">mv.setCaption( "QTreeWidget Test", false );</span>
<br><span style="font-size: 8pt;">twi.setText( 0, "Line 1");</span>
<br><span style="font-size: 8pt;">twi.setForeground( 0, fb );</span>
<br><span style="font-size: 8pt;">tw.show();</span>
<br>
<br><span style="font-size: 8pt;">return app.exec();</span>
<br><span style="font-size: 8pt;">}</span>
</div>
</div>
</body>
</html>