title: How to compile Qt 5 projects without QtCreator?
body: <p>I tried to modify KDevelop Qt 4 CMake project to be compile it with Qt 5 and changed the project, but I failed.
  I'm still learning Qt and the project's simple.
  Commented lines are replaced to make it a Qt 5 project.</p>
  
  <p>main.cpp:</p>
  
  <pre><code>//#include &lt;QtGui/QApplication&gt;
  #include &lt;qt5/QtWidgets/QApplication&gt;
  #include "Qt4_Training.h"
  
  int main(int argc, char** argv)
  {
      QApplication app(argc, argv);
      Qt4_Training qt4_training;
      qt4_training.show();
      return app.exec();
  }
  </code></pre>
  
  <p>Qt4_Training.cpp:</p>
  
  <pre><code>#include "Qt4_Training.h"
  
  /*#include &lt;QtGui/QLabel&gt;
  #include &lt;QtGui/QMenu&gt;
  #include &lt;QtGui/QMenuBar&gt;
  #include &lt;QtGui/QAction&gt;
  #include &lt;QtGui/QPushButton&gt;
  #include &lt;QTime&gt;*/
  #include &lt;qt5/QtWidgets/QLabel&gt;
  #include &lt;qt5/QtWidgets/QMenu&gt;
  #include &lt;qt5/QtWidgets/QMenuBar&gt;
  #include &lt;qt5/QtWidgets/QAction&gt;
  #include &lt;qt5/QtWidgets/QPushButton&gt;
  #include &lt;qt5/QtCore/QTime&gt;
  
  Qt4_Training::Qt4_Training()
  {
      QLabel *label = new QLabel;
      vbox = new QVBoxLayout;
  
      label.setText("Hi.");
      vbox-&gt;addWidget(label);
      QWidget *a = new QWidget;
      a-&gt;setLayout(vbox);
      setCentralWidget(a);
  
      QAction* action = new QAction(this);
      action-&gt;setText( "Quit");
      connect(action, SIGNAL(triggered()), SLOT(close()));
      menuBar()-&gt;addMenu( "File" )-&gt;addAction(action);
  }
  
  Qt4_Training::~Qt4_Training() {}
  
  //#include "Qt4_Training.moc"
  </code></pre>
  
  <p>Qt4_Training.h:</p>
  
  <pre><code>#ifndef Qt4_Training_H
  #define Qt4_Training_H
  
  /*#include &lt;QtGui/QMainWindow&gt;
  #include &lt;QtGui/QVBoxLayout&gt;*/
  #include &lt;qt5/QtWidgets/QMainWindow&gt;
  #include &lt;qt5/QtWidgets/QVBoxLayout&gt;
  
  class Qt4_Training : public QMainWindow
  {
      //Q_OBJECT
  
  public:
      QVBoxLayout *vbox;
      Qt4_Training();
      virtual ~Qt4_Training();
  };
  
  #endif // Qt4_Training_H
  </code></pre>
  
  <p>CMakeLists.txt:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.0.2)
  project(qt4_training)
  #find_package(Qt4 REQUIRED)
  find_package(Qt5Widgets REQUIRED)
  find_package(Qt5Core REQUIRED)
  
  #include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
  include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5Widgets_LIBRARIES} ${CMAKE_CURRENT_BINARY_DIR} ${Qt5Core_INCLUDE_DIRS} ${Qt5Core_LIBRARIES})
  
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
  set(Qt4_Training_SRCS Qt4_Training.cpp main.cpp)
  
  #qt4_automoc(${Qt4_Training_SRCS})
  add_executable(qt4_training ${Qt4_Training_SRCS})
  target_link_libraries(qt4_training ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
  
  install(TARGETS qt4_training RUNTIME DESTINATION bin)
  </code></pre>
  
  <p>I also tried to use Eclipse and also used '#include ', but all objects names must end with 'Private' like 'QLabelPrivate ...;'.</p>
  
  <p>KDevelop errors:</p>
  
  <pre><code>...
  CMakeFiles/qt4_training.dir/main.cpp.o: In function `main':
  main.cpp:(.text.startup+0x37): undefined reference to `QApplication::QApplication(int&amp;, char**, int)'
  main.cpp:(.text.startup+0x47): undefined reference to `QWidget::show()'
  main.cpp:(.text.startup+0x4c): undefined reference to `QApplication::exec()'
  main.cpp:(.text.startup+0x5f): undefined reference to `QApplication::~QApplication()'
  main.cpp:(.text.startup+0x96): undefined reference to `QApplication::~QApplication()'
  collect2: error: ld returned 1 exit status
  CMakeFiles/qt4_training.dir/build.make:110: recipe for target 'qt4_training' failed
  make[2]: *** [qt4_training] Error 1
  CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/qt4_training.dir/all' failed
  make[1]: *** [CMakeFiles/qt4_training.dir/all] Error 2
  Makefile:117: recipe for target 'all' failed
  make: *** [all] Error 2
  *** Failure: Exit code 2 ***
  </code></pre>
  
  <p>Eclipse errors:</p>
  
  <pre><code>In file included from ../src/Qt 5 Training.cpp:1:0:
  /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qapplication.h:37:37: fatal error: QtCore/qcoreapplication.h: No such file or directory
   #include &lt;QtCore/qcoreapplication.h&gt;
                                       ^
  compilation terminated.
  src/subdir.mk:21: recipe for target 'src/Qt 5 Training.o' failed
  make: *** [src/Qt 5 Training.o] Error 1
  </code></pre>
  
  <p>I installed libqt5widgets5, qtdeclarative5-dev, libqt5gui5, qtbase5-dev,... on Kubuntu. So do I have Qt 5?</p>