QDialogのサブクラス化

$ mkdir finddialog
$ cd finddialog
$ vi finddialog.h

$ vi finddialog.cpp

$ vi main.cpp

$ ls
./  ../  finddialog.cpp  finddialog.h  main.cpp
$ qmake -project
$ ls
./  ../  finddialog.cpp  finddialog.h  finddialog.pro  main.cpp
$ qmake finddialog.pro
Info: creating stash file /home/nakada/Qt4/finddialog/.qmake.stash
$ ls
./  ../  .qmake.stash  Makefile  finddialog.cpp  finddialog.h  finddialog.pro  main.cpp

makeを実行すると下記のエラーとなってしまう。ソースコードがQt4用になっているがインストールしたQtのバージョンが5なので互換性の問題でエラーになっているのだと思われるが…

$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o finddialog.o finddialog.cpp
finddialog.cpp:3:1: error: ‘FindDialog’ does not name a type; did you mean ‘QFontDialog’?
 FindDialog::FindDialog(QWidget *parent)
 ^~~~~~~~~~
 QFontDialog
finddialog.cpp:39:6: error: ‘FindDialog’ has not been declared
 void FindDialog::findClicked()
      ^~~~~~~~~~
finddialog.cpp: In function ‘void findClicked()’:
finddialog.cpp:41:17: error: ‘lineEdit’ was not declared in this scope
   QString text =lineEdit->text();
                 ^~~~~~~~
finddialog.cpp:43:7: error: ‘caseCheckBox’ was not declared in this scope
       caseCheckBox->isChecked() ? Qt::CaseSensitive
       ^~~~~~~~~~~~
finddialog.cpp:45:7: error: ‘backwardCheckBox’ was not declared in this scope
   if (backwardCheckBox->isChecked()) {
       ^~~~~~~~~~~~~~~~
finddialog.cpp:46:10: error: ‘findPrevious’ was not declared in this scope
     emit findPrevious(text, cs);
          ^~~~~~~~~~~~
finddialog.cpp:48:10: error: ‘findNext’ was not declared in this scope
     emit findNext(text, cs);
          ^~~~~~~~
finddialog.cpp:48:10: note: suggested alternative: ‘rindex’
     emit findNext(text, cs);
          ^~~~~~~~
          rindex
finddialog.cpp: At global scope:
finddialog.cpp:51:6: error: ‘FindDialog’ has not been declared
 void FindDialog::enableFindButton(const QString &text)
      ^~~~~~~~~~
finddialog.cpp: In function ‘void enableFindButton(const QString&)’:
finddialog.cpp:53:3: error: ‘findButton’ was not declared in this scope
   findButton->setEnabled(!text.isEmpty());
   ^~~~~~~~~~
make: *** [Makefile:373: finddialog.o] エラー 1

qt4-defaultパッケージをインストールし、Qtのバージョンを4にして再度試してみる。

$ qmake -project
$ ls
./  ../  finddialog.cpp  finddialog.h  finddialog.pro  main.cpp
$ qmake finddialog.pro
$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o finddialog.o finddialog.cpp
finddialog.cpp:3:1: error: ‘FindDialog’ does not name a type; did you mean ‘QFontDialog’?
 FindDialog::FindDialog(QWidget *parent)
 ^~~~~~~~~~
 QFontDialog
finddialog.cpp:39:6: error: ‘FindDialog’ has not been declared
 void FindDialog::findClicked()
      ^~~~~~~~~~
finddialog.cpp: In function ‘void findClicked()’:
finddialog.cpp:41:17: error: ‘lineEdit’ was not declared in this scope
   QString text =lineEdit->text();
                 ^~~~~~~~
finddialog.cpp:41:17: note: suggested alternative: ‘QLineEdit’
   QString text =lineEdit->text();
                 ^~~~~~~~
                 QLineEdit
finddialog.cpp:43:7: error: ‘caseCheckBox’ was not declared in this scope
       caseCheckBox->isChecked() ? Qt::CaseSensitive
       ^~~~~~~~~~~~
finddialog.cpp:43:7: note: suggested alternative: ‘QCheckBox’
       caseCheckBox->isChecked() ? Qt::CaseSensitive
       ^~~~~~~~~~~~
       QCheckBox
finddialog.cpp:45:7: error: ‘backwardCheckBox’ was not declared in this scope
   if (backwardCheckBox->isChecked()) {
       ^~~~~~~~~~~~~~~~
finddialog.cpp:45:7: note: suggested alternative: ‘QCheckBox’
   if (backwardCheckBox->isChecked()) {
       ^~~~~~~~~~~~~~~~
       QCheckBox
finddialog.cpp:46:10: error: ‘findPrevious’ was not declared in this scope
     emit findPrevious(text, cs);
          ^~~~~~~~~~~~
finddialog.cpp:48:10: error: ‘findNext’ was not declared in this scope
     emit findNext(text, cs);
          ^~~~~~~~
finddialog.cpp:48:10: note: suggested alternative: ‘rindex’
     emit findNext(text, cs);
          ^~~~~~~~
          rindex
finddialog.cpp: At global scope:
finddialog.cpp:51:6: error: ‘FindDialog’ has not been declared
 void FindDialog::enableFindButton(const QString &text)
      ^~~~~~~~~~
finddialog.cpp: In function ‘void enableFindButton(const QString&)’:
finddialog.cpp:53:3: error: ‘findButton’ was not declared in this scope
   findButton->setEnabled(!text.isEmpty());
   ^~~~~~~~~~
finddialog.cpp:53:3: note: suggested alternative: ‘QRadioButton’
   findButton->setEnabled(!text.isEmpty());
   ^~~~~~~~~~
   QRadioButton
make: *** [Makefile:212: finddialog.o] エラー 1

Qt4に変更してもエラーとなった。何がおかしいのか、現時点で不明…