C++ GUI Programming with Qt 4 SortDialog作成時にエラーが発生します。
C++ GUI Programming with Qt 4 gotocelldialog-作成時にエラーが発生します
と似た質問なのですが、ご勘弁ください。この質問でご回答いただいたように、
したつもりなのですが、今度は、
認識できない型 Ui::SortDialogが使われています。
Ui::SortDialogの宣言を確認してください。
というエラーが出ます。以前の回答の通りに倣って見たのですが、
スムーズにはいきませんでした。
色々とコードをいじってみて実行してみましたが、
糸が絡まるばかり。以下のコードはできるだけもとに戻して
いるつもりですが、どこをどうすればエラーが解決するのでしょうか。
特に、
sortdialog.cpp
内のui->
に下線が。
delete
に下線が引かれます。
他は事前のエラーの兆候は見受けられません。
Windows-10 Qt5.9.6 Qt-Creator4.7.0
sort.pro
#-------------------------------------------------
#
# Project created by QtCreator 2018-09-08T16:20:41
#
#-------------------------------------------------
QT += core gui widgets
TARGET = sort
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11\
uitools
SOURCES += \
main.cpp \
sortdialog.cpp
HEADERS += \
sortdialog.h
FORMS += \
sortdialog.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
sortdialog.h
#ifndef SORTDIALOG_H
#define SORTDIALOG_H
#include <QDialog>
#include "ui_sortdialog.h"
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
main.cpp
#include "sortdialog.h"
#include <QApplication>
int main(int argc, char *argv[])
{ QApplication a(argc, argv);
SortDialog *dialog = new SortDialog;
dialog->setColumnRange('C','F');
dialog->show();
return a.exec();
}
sortdialog.cpp
#include "sortdialog.h"
#include "ui_sortdialog.h"
#include <QtGui>
SortDialog::SortDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SortDialog)
{
ui->setupUi(this);
ui->secondaryGroupBox->hide();
ui->tertiaryGroupBox->hide();
layout()->setSizeConstraint(QLayout::SetFixedSize);
setColumnRange('A','Z');
}
void SortDialog::setColumnRange(QChar first,QChar last)
{
ui->primaryColumnCmbo->clear();
ui->secondaryColumnCombo->clear();
ui->tertiaryColumnCombo->clear();
ui->secondaryColumnCombo->addItem(tr("None"));
ui->tertiaryColumnCombo->addItem(tr("None"));
ui->primaryColumnCombo->setMinimumSize(
ui->secondaryColumnCombo->sizeHint());
QChar ch = first;
while (ch <= last){
ui->primaryColumnCombo->addItem(QString(ch));
ui->secondaryColumnCombo->addItem(QString(ch));
ui->tertiaryColumnCombo->addItem(QString(ch));
ch = ch.unicode() + 1;
}
}
SortDialog::~SortDialog()
{
delete ui;
}
sortdialog.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>secondaryGroupBox</class>
<widget class="QDialog" name="secondaryGroupBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>468</height>
</rect>
</property>
<property name="windowTitle">
<string>Sort</string>
</property>
<widget class="QGroupBox" name="primaryGroupBox">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>221</width>
<height>131</height>
</rect>
</property>
<property name="title">
<string>&Primary Key</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>178</width>
<height>51</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<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>48</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Column:</string>
</property>
</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="1">
<widget class="QComboBox" name="primaryColumnCombo">
<item>
<property name="text">
<string>None</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>30</x>
<y>200</y>
<width>221</width>
<height>101</height>
</rect>
</property>
<property name="title">
<string>&Secondary Key</string>
</property>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>62</width>
<height>15</height>
</rect>
</property>
<property name="text">
<string>Column:</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>62</width>
<height>15</height>
</rect>
</property>
<property name="text">
<string>Order:</string>
</property>
</widget>
<widget class="QComboBox" name="secondaryColumnCombo">
<property name="geometry">
<rect>
<x>90</x>
<y>30</y>
<width>71</width>
<height>21</height>
</rect>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="secondaryOrderCombo">
<property name="geometry">
<rect>
<x>90</x>
<y>60</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<item>
<property name="text">
<string>Ascending</string>
</property>
</item>
<item>
<property name="text">
<string>Descending</string>
</property>
</item>
</widget>
</widget>
<widget class="QGroupBox" name="tertiaryGroupBox">
<property name="geometry">
<rect>
<x>30</x>
<y>330</y>
<width>221</width>
<height>111</height>
</rect>
</property>
<property name="title">
<string>&Tertiary Key</string>
</property>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>62</width>
<height>15</height>
</rect>
</property>
<property name="text">
<string>Column:</string>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>62</width>
<height>15</height>
</rect>
</property>
<property name="text">
<string>Order:</string>
</property>
</widget>
<widget class="QComboBox" name="tertiaryColumnCombo">
<property name="geometry">
<rect>
<x>90</x>
<y>30</y>
<width>71</width>
<height>21</height>
</rect>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="tertiaryOrderCombo">
<property name="geometry">
<rect>
<x>90</x>
<y>60</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<item>
<property name="text">
<string>Ascending</string>
</property>
</item>
<item>
<property name="text">
<string>Descending</string>
</property>
</item>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>260</x>
<y>30</y>
<width>101</width>
<height>131</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<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>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="moreButton">
<property name="text">
<string>&More</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>okButton</sender>
<signal>clicked()</signal>
<receiver>secondaryGroupBox</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>320</x>
<y>56</y>
</hint>
<hint type="destinationlabel">
<x>192</x>
<y>164</y>
</hint>
</hints>
</connection>
</connections>
</ui>