Note that there are some explanatory texts on larger screens.

plurals
  1. PO(C++)Code::Blocks possible wrong setup for Qt4
    primarykey
    data
    text
    <p>OS : windows xp SP2 , compiler : Code::Blocks ver. 10.05 , Qt 4.6</p> <p>I recently started to learn Qt. At first all went well with simple tut examples. I soon came across an example that can not compile and and realized that something is wrong.</p> <p>Here is the code :</p> <pre><code>#include &lt;QWidget&gt; #include &lt;QApplication&gt; #include &lt;QPushButton&gt; #include &lt;QLabel&gt; #include &lt;QDesktopWidget&gt; class Communicate : public QWidget { Q_OBJECT public: Communicate(QWidget *parent = 0); private slots: void OnPlus(); void OnMinus(); private: QLabel *label; }; void center(QWidget *widget, int w, int h) { int x, y; int screenWidth; int screenHeight; QDesktopWidget *desktop = QApplication::desktop(); screenWidth = desktop-&gt;width(); screenHeight = desktop-&gt;height(); x = (screenWidth - w) / 2; y = (screenHeight - h) / 2; widget-&gt;move( x, y ); } Communicate::Communicate(QWidget *parent) : QWidget(parent) { int WIDTH = 350; int HEIGHT = 190; resize(WIDTH, HEIGHT); QPushButton *plus = new QPushButton("+", this); plus-&gt;setGeometry(50, 40, 75, 30); QPushButton *minus = new QPushButton("-", this); minus-&gt;setGeometry(50, 100, 75, 30); label = new QLabel("0", this); label-&gt;setGeometry(190, 80, 20, 30); connect(plus, SIGNAL(clicked()), this, SLOT(OnPlus())); connect(minus, SIGNAL(clicked()), this, SLOT(OnMinus())); center(this, WIDTH, HEIGHT); } void Communicate::OnPlus() { int val = label-&gt;text().toInt(); val++; label-&gt;setText(QString::number(val)); } void Communicate::OnMinus() { int val = label-&gt;text().toInt(); val--; label-&gt;setText(QString::number(val)); } int main(int argc, char *argv[]) { QApplication app(argc, argv); Communicate window; window.setWindowTitle("Communicate"); window.show(); return app.exec(); } </code></pre> <p>When I try to open it, I get this message:</p> <p>obj\Release\main.o:main.cpp|| undefined reference to `vtable for Communicate'|</p> <p>obj\Release\main.o:main.cpp|| undefined reference to `vtable for Communicate'|</p> <p>obj\Release\main.o:main.cpp|| undefined reference to `vtable for Communicate'|</p> <p>obj\Release\main.o:main.cpp|| undefined reference to `vtable for Communicate'|</p> <p>obj\Release\main.o:main.cpp|| undefined reference to `vtable for Communicate'|</p> <p>obj\Release\main.o:main.cpp|| more undefined references to `vtable for Communicate' follow|</p> <p>||=== Build finished: 6 errors, 0 warnings ===|</p> <p>I was looking for a solution to the code:: blocks forum and learned that there should be Qt plugin installed.</p> <p>So , I install QtWorkbench 0.6.0 alpha -> qt plugin but nothing has changed. </p> <p>Any suggestion is welcome.</p>
    singulars
    1. This table or related slice is empty.
    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