48421


**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>

再びなのですが、`UI`ファイルを作成したとき、（`QtDesigner`で、`GUI`を構築したとき）なのですが、いつも`ui->`で、橙色の波線が引かれ、  
**member Access into incomplete type UI::SortDialog**  
という警告文がエディタに表示されます。ヘッダファイルの設定が間違えているのでしょうか。それとも、コンパイラなどが違うからでしょうか。何かご存知の方はお願いいたします。

**sortdialog.cpp**

[code]

    #include "sortdialog.h"
    #include <QtGui>
    #include <QtWidgets>
    
    
    SortDialog::SortDialog(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::SortDialog)
    {
        ui->setupUi(this);#here
        ui->secondaryGroupBox->hide();#here
        ui->tertiaryGroupBox->hide();#here
        layout()->setSizeConstraint(QLayout::SetFixedSize);
        setColumnRange('A','Z');
    
    }
    void SortDialog::setColumnRange(QChar first,QChar last)
    {
        ui->primaryColumnCombo->clear();#here
        ui->secondaryColumnCombo->clear();#here
        ui->tertiaryColumnCombo->clear();#here
    
        ui->secondaryColumnCombo->addItem(tr("None"));#here
        ui->tertiaryColumnCombo->addItem(tr("None"));#here
    
        ui->primaryColumnCombo->setMinimumSize(
                    ui->secondaryColumnCombo->sizeHint());#here
        QChar ch = first;
        while (ch <= last){
            ui->primaryColumnCombo->addItem(QString(ch));#here
            ui->secondaryColumnCombo->addItem(QString(ch));#here
            ui->tertiaryColumnCombo->addItem(QString(ch));#here
            ch = ch.unicode() + 1;
        }
    }
    SortDialog::~SortDialog()
    {
        delete ui;
    }
    
[/code]

**sortdialog.h**

[code]

    #ifndef SORTDIALOG_H
    #define SORTDIALOG_H
    #include <QDialog>
    #include <QtUiTools/QUiLoader>
    namespace Ui {
    class SortDialog;
    }
    class SortDialog : public QDialog
    {
        Q_OBJECT
    public:
        SortDialog(QWidget *parent = nullptr);
        ~SortDialog();
        void setColumnRange(QChar first,QChar last);
    private:
        Ui::SortDialog *ui;
    };
    #endif // SORTDIALOG_H
    
[/code]

**sortdialog.ui**

[code]

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>SortDialog</class>
     <widget class="QDialog" name="SortDialog">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>341</width>
        <height>319</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>Sort</string>
      </property>
      <layout class="QGridLayout" name="gridLayout_4">
       <item row="0" column="0">
        <widget class="QGroupBox" name="groupBox">
         <property name="title">
          <string>&amp;Primary Key</string>
         </property>
         <layout class="QGridLayout" name="gridLayout">
          <item row="0" column="1">
           <widget class="QComboBox" name="primaryColumnCombo">
            <item>
             <property name="text">
              <string>None</string>
             </property>
            </item>
           </widget>
          </item>
          <item row="1" column="1" colspan="2">
           <widget class="QComboBox" name="primaryOrderCombo">
            <item>
             <property name="text">
              <string>Ascending</string>
             </property>
            </item>
            <item>
             <property name="text">
              <string>Descending</string>
             </property>
            </item>
           </widget>
          </item>
          <item row="0" column="0">
           <widget class="QLabel" name="label">
            <property name="text">
             <string>Column:</string>
            </property>
           </widget>
          </item>
          <item row="1" column="0">
           <widget class="QLabel" name="label_2">
            <property name="text">
             <string>Order:</string>
            </property>
           </widget>
          </item>
          <item row="0" column="2">
           <spacer name="horizontalSpacer">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>62</width>
              <height>13</height>
             </size>
            </property>
           </spacer>
          </item>
         </layout>
        </widget>
       </item>
       <item row="0" column="1" rowspan="2">
        <layout class="QVBoxLayout" name="verticalLayout_2">
         <item>
          <widget class="QPushButton" name="okButton">
           <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>
         <item>
          <spacer name="verticalSpacer">
           <property name="orientation">
            <enum>Qt::Vertical</enum>
           </property>
           <property name="sizeHint" stdset="0">
            <size>
             <width>0</width>
             <height>20</height>
            </size>
           </property>
          </spacer>
         </item>
         <item>
          <widget class="QPushButton" name="moreButton">
           <property name="text">
            <string>&amp;More</string>
           </property>
           <property name="checkable">
            <bool>true</bool>
           </property>
          </widget>
         </item>
        </layout>
       </item>
       <item row="1" column="0">
        <spacer name="verticalSpacer_2">
         <property name="orientation">
          <enum>Qt::Vertical</enum>
         </property>
         <property name="sizeHint" stdset="0">
          <size>
           <width>0</width>
           <height>9</height>
          </size>
         </property>
        </spacer>
       </item>
       <item row="2" column="0">
        <widget class="QGroupBox" name="groupBox_2">
         <property name="title">
          <string>&amp;Secondary Kye</string>
         </property>
         <layout class="QGridLayout" name="gridLayout_2">
          <item row="0" column="1">
           <widget class="QComboBox" name="secondaryColumnCombo">
            <item>
             <property name="text">
              <string>None</string>
             </property>
            </item>
           </widget>
          </item>
          <item row="1" column="1" colspan="2">
           <widget class="QComboBox" name="secondaryOrderCombo">
            <item>
             <property name="text">
              <string>Ascending</string>
             </property>
            </item>
            <item>
             <property name="text">
              <string>Descending</string>
             </property>
            </item>
           </widget>
          </item>
          <item row="0" column="0">
           <widget class="QLabel" name="label_3">
            <property name="text">
             <string>Column:</string>
            </property>
           </widget>
          </item>
          <item row="1" column="0">
           <widget class="QLabel" name="label_4">
            <property name="text">
             <string>Order:</string>
            </property>
           </widget>
          </item>
          <item row="0" column="2">
           <spacer name="horizontalSpacer_2">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>116</width>
              <height>13</height>
             </size>
            </property>
           </spacer>
          </item>
         </layout>
        </widget>
       </item>
       <item row="3" column="0">
        <widget class="QGroupBox" name="groupBox_3">
         <property name="title">
          <string>&amp;Tertiary Key</string>
         </property>
         <layout class="QGridLayout" name="gridLayout_3">
          <item row="0" column="1">
           <widget class="QComboBox" name="tertiaryColumnCombo">
            <item>
             <property name="text">
              <string>None</string>
             </property>
            </item>
           </widget>
          </item>
          <item row="1" column="1" colspan="2">
           <widget class="QComboBox" name="tertiaryOrderCombo">
            <item>
             <property name="text">
              <string>Ascending</string>
             </property>
            </item>
            <item>
             <property name="text">
              <string>Descending</string>
             </property>
            </item>
           </widget>
          </item>
          <item row="0" column="0">
           <widget class="QLabel" name="label_5">
            <property name="text">
             <string>Column:</string>
            </property>
           </widget>
          </item>
          <item row="1" column="0">
           <widget class="QLabel" name="label_6">
            <property name="text">
             <string>Order:</string>
            </property>
           </widget>
          </item>
          <item row="0" column="2">
           <spacer name="horizontalSpacer_3">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>116</width>
              <height>13</height>
             </size>
            </property>
           </spacer>
          </item>
         </layout>
        </widget>
       </item>
      </layout>
     </widget>
     <layoutdefault spacing="6" margin="11"/>
     <resources/>
     <connections>
      <connection>
       <sender>okButton</sender>
       <signal>clicked()</signal>
       <receiver>SortDialog</receiver>
       <slot>accept()</slot>
       <hints>
        <hint type="sourcelabel">
         <x>274</x>
         <y>37</y>
        </hint>
        <hint type="destinationlabel">
         <x>105</x>
         <y>102</y>
        </hint>
       </hints>
      </connection>
      <connection>
       <sender>cancelButton</sender>
       <signal>clicked()</signal>
       <receiver>SortDialog</receiver>
       <slot>reject()</slot>
       <hints>
        <hint type="sourcelabel">
         <x>296</x>
         <y>66</y>
        </hint>
        <hint type="destinationlabel">
         <x>177</x>
         <y>108</y>
        </hint>
       </hints>
      </connection>
      <connection>
       <sender>moreButton</sender>
       <signal>toggled(bool)</signal>
       <receiver>groupBox_2</receiver>
       <slot>setVisible(bool)</slot>
       <hints>
        <hint type="sourcelabel">
         <x>311</x>
         <y>99</y>
        </hint>
        <hint type="destinationlabel">
         <x>185</x>
         <y>159</y>
        </hint>
       </hints>
      </connection>
      <connection>
       <sender>moreButton</sender>
       <signal>toggled(bool)</signal>
       <receiver>groupBox_3</receiver>
       <slot>setVisible(bool)</slot>
       <hints>
        <hint type="sourcelabel">
         <x>327</x>
         <y>111</y>
        </hint>
        <hint type="destinationlabel">
         <x>209</x>
         <y>258</y>
        </hint>
       </hints>
      </connection>
     </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-15T06:13:03.437
48419
2018-10-10T00:38:23.823
2018-10-10T00:38:23.823
2238
24284
question
c++11 qt5 qt-creator
C++ GUI Programming with Qt 4 UIのエラー


`sortdialog.cpp`へ`ui_sortdialog.h`のヘッダファイルをインクルードします。  
すると`ui->`のエラーは解消します。  
解決です。


CC BY-SA 4.0
2018-09-15T07:07:40.123
48421
2018-09-15T07:14:56.067
2018-09-15T07:14:56.067
24284
24284
48419
answer