Hi all, I've just started using qt and I've run into the problem of constantly getting
undefined reference to 'vtable for window'
Witch is strange cause I was able to run some of the tutorial examples but this one just wont work.
I'm using Kdevelop 3.5 on ubuntu 7.04 and using qt4
window.h
Qt Code:
  1. /***************************************************************************
  2.  * Copyright (C) 2007 by adriaan,,, *
  3.  * adriaan@Tornado *
  4.  * *
  5.  * This program is free software; you can redistribute it and/or modify *
  6.  * it under the terms of the GNU General Public License as published by *
  7.  * the Free Software Foundation; either version 2 of the License, or *
  8.  * (at your option) any later version. *
  9.  * *
  10.  * This program is distributed in the hope that it will be useful, *
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13.  * GNU General Public License for more details. *
  14.  * *
  15.  * You should have received a copy of the GNU General Public License *
  16.  * along with this program; if not, write to the *
  17.  * Free Software Foundation, Inc., *
  18.  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19.  ***************************************************************************/
  20.  
  21. #pragma once
  22.  
  23. #include <QApplication>
  24. #include <QtGui>
  25. #include <QWidget>
  26. #include <QComboBox>
  27. #include <QLineEdit>
  28. #include <QtGui>
  29. #include <QGridLayout>
  30. #include <QGroupBox>
  31. #include <QPushButton>
  32. #include <QLabel>
  33.  
  34.  
  35. class window : public QWidget
  36. {
  37.  
  38. public:
  39.  
  40. window(QWidget * parent = NULL);
  41.  
  42. ~window();
  43.  
  44. private:
  45.  
  46. QLineEdit * nameline;
  47.  
  48. QLineEdit * typeline;
  49.  
  50. QLineEdit * answerline;
  51.  
  52. };
To copy to clipboard, switch view to plain text mode 
window.cpp
Qt Code:
  1. /***************************************************************************
  2.  * Copyright (C) 2007 by adriaan,,, *
  3.  * adriaan@Tornado *
  4.  * *
  5.  * This program is free software; you can redistribute it and/or modify *
  6.  * it under the terms of the GNU General Public License as published by *
  7.  * the Free Software Foundation; either version 2 of the License, or *
  8.  * (at your option) any later version. *
  9.  * *
  10.  * This program is distributed in the hope that it will be useful, *
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13.  * GNU General Public License for more details. *
  14.  * *
  15.  * You should have received a copy of the GNU General Public License *
  16.  * along with this program; if not, write to the *
  17.  * Free Software Foundation, Inc., *
  18.  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19.  ***************************************************************************/
  20.  
  21.  
  22. #include "window.h"
  23.  
  24. window::window(QWidget * var) : QWidget(var)
  25. {
  26.  
  27. /*=================================================
  28. * Settings *
  29. =================================================*/
  30.  
  31. setWindowTitle("Variable Definer Version 0.1");
  32.  
  33. /*=================================================
  34. * Name *
  35. =================================================*/
  36.  
  37. QGroupBox * namegroup = new QGroupBox("Name");
  38.  
  39. QLabel * namelabel = new QLabel("Enter variable name:");
  40.  
  41. nameline = new QLineEdit();
  42.  
  43. nameline->setFocus();
  44.  
  45. QGridLayout * namelayout = new QGridLayout;
  46.  
  47. namelayout->addWidget(namelabel, 0, 0);
  48.  
  49. namelayout->addWidget(nameline, 1, 0,1,2);
  50.  
  51. namegroup->setLayout(namelayout);
  52.  
  53. /*=================================================
  54. * Type *
  55. =================================================*/
  56.  
  57. QGroupBox * typegroup = new QGroupBox("Type");
  58.  
  59. QLabel * typeLabel = new QLabel("Enter variable type");
  60.  
  61. typeline = new QLineEdit();
  62.  
  63. QGridLayout * typelayout = new QGridLayout();
  64.  
  65. typelayout->addWidget(typeLabel, 0, 0);
  66.  
  67. typelayout->addWidget(typeline, 1,0,1,2);
  68.  
  69. typegroup->setLayout(typelayout);
  70.  
  71. /*=================================================
  72. * Specifiers *
  73. =================================================*/
  74.  
  75. QGroupBox * specgroup = new QGroupBox("Specifiers");
  76.  
  77. QLabel * speclabel = new QLabel("Choose the right defenition");
  78.  
  79. QPushButton * array = new QPushButton("Array (of)");
  80.  
  81. QPushButton * pointer = new QPushButton("Pointer (to)");
  82.  
  83. QPushButton * function = new QPushButton("Function");
  84.  
  85. QGridLayout * speclay = new QGridLayout();
  86.  
  87. speclay->addWidget(speclabel,0,0);
  88.  
  89. speclay->addWidget(array,1,0);
  90.  
  91. speclay->addWidget(pointer,1,1);
  92.  
  93. speclay->addWidget(function,1,2);
  94.  
  95. specgroup->setLayout(speclay);
  96.  
  97. /*=================================================
  98. * Answer *
  99. =================================================*/
  100.  
  101. QGroupBox * answergroup = new QGroupBox("Defenition");
  102.  
  103. QLabel * answerlabel = new QLabel("The correct defenition:");
  104.  
  105. answerline = new QLineEdit();
  106.  
  107. QGridLayout * anslay= new QGridLayout();
  108.  
  109. anslay->addWidget(answerlabel,0,0);
  110.  
  111. anslay->addWidget(answerline,1,0,1,2);
  112.  
  113. answergroup->setLayout(anslay);
  114.  
  115. /*=================================================
  116. * Global Layout *
  117. =================================================*/
  118.  
  119. QGridLayout * layout = new QGridLayout();
  120.  
  121. layout->addWidget(namegroup, 0, 0);
  122.  
  123. layout->addWidget(typegroup, 1, 0);
  124.  
  125. layout->addWidget(specgroup, 2, 0);
  126.  
  127. layout->addWidget(answergroup,3, 0);
  128.  
  129. setLayout(layout);
  130.  
  131. }
To copy to clipboard, switch view to plain text mode 
main.cpp
Qt Code:
  1. /***************************************************************************
  2.  * Copyright (C) 2007 by adriaan,,, *
  3.  * adriaan@Tornado *
  4.  * *
  5.  * This program is free software; you can redistribute it and/or modify *
  6.  * it under the terms of the GNU General Public License as published by *
  7.  * the Free Software Foundation; either version 2 of the License, or *
  8.  * (at your option) any later version. *
  9.  * *
  10.  * This program is distributed in the hope that it will be useful, *
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13.  * GNU General Public License for more details. *
  14.  * *
  15.  * You should have received a copy of the GNU General Public License *
  16.  * along with this program; if not, write to the *
  17.  * Free Software Foundation, Inc., *
  18.  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19.  ***************************************************************************/
  20.  
  21.  
  22. #include <QApplication>
  23.  
  24. #include "window.h"
  25.  
  26. int main(int argc, char *argv[])
  27. {
  28.  
  29. QApplication application (argc, argv);
  30.  
  31. window * newwindow = new window();
  32.  
  33. newwindow->show();
  34.  
  35. return (application.exec());
  36.  
  37. }
To copy to clipboard, switch view to plain text mode