

**Source Code**  
<http://www.informit.com/store/c-plus-plus-gui-programming-with-
qt4-9780132354165>  
**PDF File**  
<https://www.researchgate.net/publication/215458943_C_GUI_programming_with_Qt_4>

引き続きお願いします。

`mainwindow.cpp`ファイルで余計なメンバ関数は省いています。  
下記のエラーが発生します。

1.lineEdit is a private member of 'GoToCellDialog'  
2.variable has imcomplete type SpreadSheetCompare  
3.no member named "name" in SortDialog

`SortDialog`と`GoToCellDialog`が関わっているようなのですが、どこがどうなっているのでしょうか。SortDialogについては[C++
GUI Programming with Qt 4
UIのエラー](https://ja.stackoverflow.com/questions/48419/c-gui-programming-with-
qt-4-ui%E3%81%AE%E3%82%A8%E3%83%A9%E3%83%BC)直前の質問でコードを載せてますので、申し訳ありませんがそちらをご覧ください。`GoToCellDialog`はここに載せます。（過去に掲載はしましたが不完全なので。）

**mainwindow.cpp**

[code]

    #include "mainwindow.h"
    #include "gotocelldialog.h"
    #include "sortdialog.h"
    #include "spreadsheet.h"
    #include "finddialog.h"
    #include "ui_gotocelldialog.h"
    #include "ui_sortdialog.h"
    #include <QtWidgets>
    #include <QtGui>
    
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
    {   spreadsheet = new Spreadsheet;
        setCentralWidget(spreadsheet);
    
        createActions();
        createMenus();
        createContextMenu();
        createToolBars();
        createStatusBar();
        readSettings();
        findDialog = nullptr;
        setWindowIcon(QIcon(":/images/icon.png"));
        setCurrentFile("");
    
    
    }
    
    省略～
    
    
    
    void MainWindow::goToCell()
    {
                GoToCellDialog *dialog = new GoToCellDialog(this);
                if (dialog->exec()){
                    QString str = dialog->lineEdit->text().toUpper();#here lineEdit is a private member of 'GoToCellDialog'
                    spreadsheet->setCurrentCell(str.mid(1).toInt() -1,
                                                str[0].unicode() - 'A');
                }
            }
    void MainWindow::sort()
    {
                SortDialog *dialog = new SortDialog(this);
                QTableWidgetSelectionRange range = spreadsheet->selectedRange();
                dialog->setColumnRange('A' + range.leftColumn(),
                                      'A' + range.rightColumn());
                if (dialog.exec()){
                    SpreadSheetCompare compare;\\unknown type name "SpreadSheetCompare"
                    compare.keys[0] =
                    dialog->primaryColumnCombo->currentIndex() - 1;//here no member named "primaryColumnCombo" in SortDialog
                    compare.keys[1] =
                    dialog.secondaryColumnCombo->currentIndex() - 1;//here also
                    compare.ascending[0] =
                    (dialog.primaryOrderCombo->currentIndex() == 0);//here also
                    compare.ascending[1] =
                    (dialog.secondaryOrderCombo->currentIndex() == 0);//here also
                    compare.ascending[2] =
                    (dialog.tertiaryOrderCombo->currentIndex() == 0);//here  also
                    spreadsheet->sort(compare);
                }
            }
    
    
    
    MainWindow::~MainWindow()
    {
    
    }
    
[/code]

**mainwindow.h**

[code]

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    class QAction;
    class QLabel;
    class FindDialog;
    class SortDialog;
    class GoToCellDialog;
    class SpreadSheetCompare;
    class Spreadsheet;
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    protected:
        void closeEvent(QCloseEvent *event);
    private slots:
        void newFile();
        void open();
        bool save();
        bool saveAs();
        void find();
        void goToCell();
        void sort();
        void about();
        void openRecentFile();
        void updateStatusBar();
        void spreadsheetModified();
    private:
        void createActions();
        void createMenus();
        void createContextMenu();
        void createToolBars();
        void createStatusBar();
        void readSettings();
        void writeSettings();
        bool okToContinue();
        bool loadFile(const QString &fileName);
        bool saveFile(const QString &fileName);
        void setCurrentFile(const QString &fileName);
        void updateRecentFileActions();
        QString strippedName(const QString &fullFileName);
    
        Spreadsheet *spreadsheet;
        FindDialog *findDialog;
        QLabel *locationLabel;
        QLabel *formulaLabel;
        QStringList recentFiles;
        QString curFile;
        enum {MaxRecentFiles = 5};
        QAction *recentFileActions[MaxRecentFiles];
        QAction *separatorAction;
    
        QMenu *fileMenu;
        QMenu *editMenu;
        QMenu *selectSubMenu;
        QMenu *toolsMenu;
        QMenu *optionsMenu;
        QMenu *helpMenu;
        QToolBar *fileToolBar;
        QToolBar *editToolBar;
        QAction *newAction;
        QAction *openAction;
        QAction *exitAction;
        QAction *selectAllAction;
        QAction *showGridAction;
        QAction *aboutAction;
        QAction *aboutQtAction;
        QAction *saveAction;
        QAction *saveAsAction;
        QAction *cutAction;
        QAction *copyAction;
        QAction *deleteAction;
        QAction *pasteAction;
        QAction *findAction;
        QAction *goToCellAction;
        QAction *selectRowAction;
        QAction *selectColumnAction;
        QAction *recalculateAction;
        QAction *sortAction;
        QAction *autoRecalcAction;
    
    
    
    };
    
    
    #endif // MAINWINDOW_H
    
[/code]

**gotocelldialog.h**

[code]

    #ifndef GOTOCELLDIALOG_H
    #define GOTOCELLDIALOG_H
    #include <QDialog>
    #include <QLineEdit>
    
    
    #include <QtUiTools/QUiLoader>
    namespace Ui {
    class GoToCellDialog;
    }
    class GoToCellDialog : public QDialog
    {
        Q_OBJECT
    public:
        GoToCellDialog(QWidget *parent=nullptr);
    private slots:
        void on_lineEdit_textChanged();
    private:
        QPushButton *okButton;
        QPushButton *cancelButton;
        QLineEdit *lineEdit;
        Ui::GoToCellDialog *ui;
        };
    
    #endif // GOTOCELLDIALOG_H
    
[/code]

**gotocelldialog.cpp**

[code]

    #include <QtGui>
    #include <QtWidgets>
    #include <QtCore>
    #include <QRegExpValidator>
    #include "gotocelldialog.h"
    #include "ui_gotocelldialog.h"
    
    GoToCellDialog::GoToCellDialog(QWidget *parent)
        :QDialog(parent)
    
    {
        ui->setupUi(this);
    
        QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
        ui->lineEdit->setValidator(new QRegExpValidator(regExp,this));
    
        connect(okButton,SIGNAL(clicked()),this,SLOT(accept()));
        connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
    }
    void GoToCellDialog::on_lineEdit_textChanged()
    {
        okButton->setEnabled(ui->lineEdit->hasAcceptableInput());
    }
    
[/code]

**gotocelldialog.ui**

[code]

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>GoToCellDialog</class>
     <widget class="QDialog" name="GoToCellDialog">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>384</width>
        <height>208</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>Go to Cell</string>
      </property>
      <widget class="QWidget" name="">
       <property name="geometry">
        <rect>
         <x>60</x>
         <y>70</y>
         <width>249</width>
         <height>62</height>
        </rect>
       </property>
       <layout class="QVBoxLayout" name="verticalLayout">
        <item>
         <layout class="QHBoxLayout" name="horizontalLayout">
          <item>
           <widget class="QLabel" name="label">
            <property name="text">
             <string>&amp;Cell Location</string>
            </property>
            <property name="buddy">
             <cstring>lineEdit</cstring>
            </property>
           </widget>
          </item>
          <item>
           <widget class="QLineEdit" name="lineEdit"/>
          </item>
         </layout>
        </item>
        <item>
         <layout class="QHBoxLayout" name="horizontalLayout_2">
          <item>
           <spacer name="horizontalSpacer">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
             </size>
            </property>
           </spacer>
          </item>
          <item>
           <widget class="QPushButton" name="okButton">
            <property name="enabled">
             <bool>false</bool>
            </property>
            <property name="text">
             <string>OK</string>
            </property>
            <property name="default">
             <bool>true</bool>
            </property>
           </widget>
          </item>
          <item>
           <widget class="QPushButton" name="cancelButton">
            <property name="text">
             <string>Cancel</string>
            </property>
           </widget>
          </item>
         </layout>
        </item>
       </layout>
      </widget>
     </widget>
     <resources/>
     <connections/>
    </ui>
    
[/code]

* * *

**実行環境**  
qtcreator 4.7  
qt 5.9.6  
c++11  
**コンパイラ** :

`Desktop_Qt_5_9_6_MSVC2017_64bit`


CC BY-SA 4.0
2018-09-15T07:45:34.473
48422
2018-10-10T00:37:54.383
2018-10-10T00:37:54.383
2238
24284
question
c++11 qt5 qt-creator
C++ GUI Programming with Qt 4 エラーが起きます