You are not logged in.

1

Saturday, July 3rd 2010, 6:16pm

field has incomplete type / return type is incomplete type

When I run this program, I get the errors "field 'myCurrentProjectSettings' has incomplete type" and "return type 'struct "BarGraphSettings' is incomplete type. They both have to do with OptionsDialog, so I included those files as well as BarGraphSettings files. I thought this meant I didn't put "class BarGraphSettings;" at the the top of OptionsDialog, but that's not it. Or perhaps I made a typo in BarGraphSettings, but I haven't found any.

Thanks for the help!


////////////////////////////////////
Options Dialog Header
////////////////////////////////////

#ifndef OPTIONSDIALOG_H
#define OPTIONSDIALOG_H

#include <QDialog>
#include <QCheckBox>
#include <QLineEdit>
#include <QListWidgetItem>
#include "colorbox.h"
class QTabWidget;
class QComboBox;
class QLabel;
class QListWidget;
class QListWidgetItem;
class QRadioButton;
class BarGraphSettings;

class OptionsDialog : public QDialog
{
Q_OBJECT

public:
enum BarColorType { Solid, Gradient };

OptionsDialog(QWidget *parent = 0);

void setCurrentProjectSettings(BarGraphSettings settings);
void setNewProjectsSettings(BarGraphSettings settings);

bool isCurrentProjectSelected() const
{ return currentProjectItem->isSelected(); }
bool isNewProjectsSelected() const
{ return newProjectsItem->isSelected(); }

bool drawingTitle() const
{ return drawTitleCheckBox->isChecked(); }
bool drawingYAxisTitle() const
{ return drawYAxisTitleCheckBox->isChecked(); }

QString title() const
{ return titleLineEdit->text(); }
QColor titleColor() const
{ return titleColorBox->color(); }
QFont titleFont() const;

QColor backgroundColor() const
{ return bgColorBox->color(); }

BarColorType barColorType() const;
QColor solidColor() const
{ return barColorBox->color(); }
QColor lowColor() const
{ return lowBarColorBox->color(); }
QColor highColor() const
{ return highBarColorBox->color(); }

BarGraphSettings currentProjectSettings() const
{ return myCurrentProjectSettings; }
BarGraphSettings newProjectsSettings() const
{ return myNewProjectsSettings; }

public slots:
void accept();
void reset();
void comboBoxItemSelected(QString itemText);
void chooseFont();
void selectedItemChanged(QListWidgetItem *newItem,
QListWidgetItem *oldItem);

private:
void createInterface();
void createGeneralTab();
void createProjectsTab();
void layoutInterface();
void layoutGeneralTab();
void layoutProjectsTab();
void setSettings(BarGraphSettings &settings);
void saveSettings(BarGraphSettings &settings);
void loadSettings(BarGraphSettings settings);

QMap<QListWidgetItem*,BarGraphSettings> settingsMap;

BarGraphSettings myCurrentProjectSettings;
BarGraphSettings myNewProjectsSettings;

QFont defaultTitleFont;
QColor defaultTitleColor;
QColor defaultBgColor;
QColor defaultSolidBarColor;
QColor defaultLowBarColor;
QColor defaultHighBarColor;

QTabWidget *tabWidget;
QWidget *generalTab;
QWidget *projectsTab;

// General Tab
QLabel *studentCompletedLabel;
QButtonGroup *studentCompletedGroup;
QRadioButton *archiveRadioButton;
QRadioButton *promptArchiveRadioButton;
QRadioButton *removeRadioButton;

QCheckBox *autoLoadCheckBox;
QButtonGroup *autoLoadGroup;
QRadioButton *prevOpenedProjRadioButton;
QRadioButton *specProjRadioButton;
QLineEdit *specProjLineEdit;
QPushButton *specProjButton;

QLabel *archiveGroupLabel;
QButtonGroup *archiveGroup;
QRadioButton *monthRadioButton;
QRadioButton *yearRadioButton;
QRadioButton *noneRadioButton;
QButtonGroup *sortValueGroup;
QRadioButton *dateCompletedRadioButton;
QRadioButton *dateStartedRadioButton;

// Projects Tab
QListWidget *projectsListWidget;
QListWidgetItem *newProjectsItem;
QListWidgetItem *currentProjectItem;

QCheckBox *drawTitleCheckBox;
QLabel *titleLabel;
QLineEdit *titleLineEdit;
QLabel *titleColorLabel;
ColorBox *titleColorBox;
QLabel *titleFontLabel;
QLineEdit *titleFontLineEdit;
QPushButton *titleFontButton;

QCheckBox *drawYAxisTitleCheckBox;

QLabel *bgColorLabel;
QLabel *barColorLabel;
QLabel *solidBarColorLabel;
QLabel *lowBarColorLabel;
QLabel *highBarColorLabel;

QComboBox *barColorComboBox;

ColorBox *bgColorBox;
ColorBox *barColorBox;
ColorBox *lowBarColorBox;
ColorBox *highBarColorBox;

// Bottom Buttons
QPushButton *resetButton;
QPushButton *okButton;
QPushButton *cancelButton;
};

#endif
//////////////////////////////////////////////

/////////////////////////
OptionsDialog Source
/////////////////////////

#include <QtGui>
#include "optionsdialog.h"
#include "colorbox.h"
#include "bargraphsettings.h"

//
// Public Functions
//
OptionsDialog::OptionsDialog(QWidget *parent)
: QDialog(parent),
defaultTitleFont("Times New Roman", 16, QFont::Bold)
{
defaultTitleColor = Qt::black;
defaultBgColor = Qt::white;
defaultSolidBarColor = Qt::blue;
defaultLowBarColor = Qt::red;
defaultHighBarColor = Qt::green;

createInterface();
layoutInterface();

setSettings(myCurrentProjectSettings);
setSettings(myNewProjectsSettings);

settingsMap.insert(currentProjectItem, myCurrentProjectSettings);
settingsMap.insert(newProjectsItem, myNewProjectsSettings);

comboBoxItemSelected("Solid");

setWindowTitle(tr("Options..."));
}

void OptionsDialog::setCurrentProjectSettings(BarGraphSettings settings)
{
if (settings)
{
myCurrentProjectSettings = settings;
if (currentProjectItem->isSelected())
loadSettings(myCurrentProjectSettings);
}
}
void OptionsDialog::setNewProjectsSettings(BarGraphSettings settings)
{
if (settings)
{
myNewProjectsSettings = settings;
if (newProjectsItem->isSelected())
loadSettings(myNewProjectsSettings);
}
}

OptionsDialog::BarColorType OptionsDialog::barColorType() const
{
if (barColorComboBox->currentText() == "Solid")
return Solid;
return Gradient;
}

QFont OptionsDialog::titleFont() const
{
QFont font;
font.fromString(titleFontLineEdit->text());
return font;
}


//
// Public Slots
//
void OptionsDialog::accept()
{
saveSettings(settingsMap.value(projectsListWidget->currentItem()));
QDialog::accept();
}

void OptionsDialog::reset()
{
barColorComboBox->setCurrentIndex(0);
drawTitleCheckBox->setChecked(false);
drawYAxisTitleCheckBox->setChecked(false);
titleLineEdit->setText("");
titleFontLineEdit->setText(defaultTitleFont.toString());
titleColorBox->setColor(defaultTitleColor);
bgColorBox->setColor(defaultBgColor);
barColorBox->setColor(defaultSolidBarColor);
lowBarColorBox->setColor(defaultLowBarColor);
highBarColorBox->setColor(defaultHighBarColor);
}

void OptionsDialog::comboBoxItemSelected(QString itemText)
{
if (itemText == "Solid")
{
solidBarColorLabel->setVisible(true);
barColorBox->setVisible(true);

lowBarColorLabel->setVisible(false);
highBarColorLabel->setVisible(false);
lowBarColorBox->setVisible(false);
highBarColorBox->setVisible(false);
}
else
{
solidBarColorLabel->setVisible(false);
barColorBox->setVisible(false);

lowBarColorLabel->setVisible(true);
highBarColorLabel->setVisible(true);
lowBarColorBox->setVisible(true);
highBarColorBox->setVisible(true);
}
}

void OptionsDialog::chooseFont()
{
bool trueVar = true;
bool *truePtr = &trueVar;
QFont font = QFontDialog::getFont(truePtr, titleFont(),
this, tr("Choose a title font..."));
titleFontLineEdit->setText(tr("%1").arg(font.toString()));
}

void OptionsDialog::selectedItemChanged(QListWidgetItem *newItem,
QListWidgetItem *oldItem)
{
BarGraphSettings &settings = settingsMap.value(oldItem);
saveSettings(settings);

BarGraphSettings newSettings = settingsMap.value(newItem);
loadSettings(newSettings);
}


//
// Private Functions
//
void OptionsDialog::createInterface()
{
generalTab = new QWidget;
projectsTab = new QWidget;

createGeneralTab();
createProjectsTab();

resetButton = new QPushButton(tr("Reset"));
connect(resetButton, SIGNAL(clicked()), this, SLOT(reset()));
okButton = new QPushButton(tr("OK"));
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
cancelButton = new QPushButton(tr("Cancel"));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
void OptionsDialog::createGeneralTab()
{
studentCompletedLabel = new QLabel(tr("On student completion..."));
studentCompletedGroup = new QButtonGroup(this);
archiveRadioButton = new QRadioButton(tr("Archive student"));
promptArchiveRadioButton = new QRadioButton(tr("Prompt before archiving"));
removeRadioButton = new QRadioButton(tr("Remove student from project"));
studentCompletedGroup->addButton(archiveRadioButton);
studentCompletedGroup->addButton(promptArchiveRadioButton);
studentCompletedGroup->addButton(removeRadioButton);

autoLoadCheckBox = new QCheckBox(tr("Automatically load project"));
autoLoadGroup = new QButtonGroup(this);
prevOpenedProjRadioButton = new QRadioButton(tr("Previously opened project"));
specProjRadioButton = new QRadioButton(tr("This project"));
specProjLineEdit = new QLineEdit;
specProjButton = new QPushButton(tr("Browse"));
autoLoadGroup->addButton(prevOpenedProjRadioButton);
autoLoadGroup->addButton(specProjRadioButton);

archiveGroupLabel = new QLabel(tr("Group archives by..."));
archiveGroup = new QButtonGroup(this);
monthRadioButton = new QRadioButton(tr("Month"));
yearRadioButton = new QRadioButton(tr("Year"));
noneRadioButton = new QRadioButton(tr("Don't group"));
archiveGroup->addButton(monthRadioButton);
archiveGroup->addButton(yearRadioButton);
archiveGroup->addButton(noneRadioButton);
sortValueGroup = new QButtonGroup(this);
dateCompletedRadioButton = new QRadioButton(tr("Date completed"));
dateStartedRadioButton = new QRadioButton(tr("Date started"));
sortValueGroup->addButton(dateCompletedRadioButton);
sortValueGroup->addButton(dateStartedRadioButton);
}
void OptionsDialog::createProjectsTab()
{
tabWidget = new QTabWidget;
tabWidget->addTab(generalTab, tr("General"));
tabWidget->addTab(projectsTab, tr("Projects"));

drawTitleCheckBox = new QCheckBox(tr("Draw title"));
titleLabel = new QLabel(tr("Title"));
titleLineEdit = new QLineEdit;
titleColorLabel = new QLabel(tr("Title color"));
titleColorBox = new ColorBox(defaultTitleColor);
titleFontLabel = new QLabel(tr("Title font"));
titleFontLineEdit = new QLineEdit;
titleFontButton = new QPushButton(tr("Choose font..."));
connect(titleFontButton, SIGNAL(clicked()), this, SLOT(chooseFont()));

drawYAxisTitleCheckBox = new QCheckBox(tr("Draw Y axis title"));

bgColorLabel = new QLabel(tr("Background Color"));
barColorLabel = new QLabel(tr("Bar Color"));
solidBarColorLabel = new QLabel(tr("Color"));
lowBarColorLabel = new QLabel(tr("0%"));
highBarColorLabel = new QLabel(tr("100%"));

barColorComboBox = new QComboBox;
barColorComboBox->addItem(tr("Solid"));
barColorComboBox->addItem(tr("Gradient"));
connect(barColorComboBox, SIGNAL(currentIndexChanged(QString)),
this, SLOT(comboBoxItemSelected(QString)));

bgColorBox = new ColorBox(defaultBgColor);
barColorBox = new ColorBox(defaultSolidBarColor);
lowBarColorBox = new ColorBox(defaultLowBarColor);
highBarColorBox = new ColorBox(defaultHighBarColor);

projectsListWidget = new QListWidget;
projectsListWidget->setMaximumWidth(150);
newProjectsItem = new QListWidgetItem(tr("New Projects"));
currentProjectItem = new QListWidgetItem(tr("%1").arg("Current Project"));
projectsListWidget->addItem(newProjectsItem);
projectsListWidget->addItem(currentProjectItem);
projectsListWidget->setCurrentItem(newProjectsItem);
connect(projectsListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(selectedItemChanged(QListWidgetItem*,QListWidgetItem*)));
}

void OptionsDialog::layoutInterface()
{
layoutGeneralTab();
layoutProjectsTab();

QHBoxLayout *bottomButtonsLayout = new QHBoxLayout;
bottomButtonsLayout->addWidget(resetButton);
bottomButtonsLayout->addSpacerItem(
new QSpacerItem(100, 0, QSizePolicy::Expanding));
bottomButtonsLayout->addWidget(okButton);
bottomButtonsLayout->addWidget(cancelButton);

QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(tabWidget);
mainLayout->addLayout(bottomButtonsLayout);
setLayout(mainLayout);
}
void OptionsDialog::layoutGeneralTab()
{
QVBoxLayout *generalTabLayout = new QVBoxLayout;
generalTabLayout->addWidget(studentCompletedLabel);
generalTabLayout->addWidget(archiveRadioButton);
generalTabLayout->addWidget(promptArchiveRadioButton);
generalTabLayout->addWidget(removeRadioButton);

generalTabLayout->addSpacerItem(new QSpacerItem(0, 20,
QSizePolicy::Expanding, QSizePolicy::Expanding));

generalTabLayout->addWidget(autoLoadCheckBox);
generalTabLayout->addWidget(prevOpenedProjRadioButton);
QHBoxLayout *specProjLayout = new QHBoxLayout;
specProjLayout->addWidget(specProjRadioButton);
specProjLayout->addWidget(specProjLineEdit);
specProjLayout->addWidget(specProjButton);
generalTabLayout->addLayout(specProjLayout);

generalTabLayout->addSpacerItem(new QSpacerItem(0, 20,
QSizePolicy::Expanding, QSizePolicy::Expanding));

generalTabLayout->addWidget(archiveGroupLabel);
QHBoxLayout *archiveGroupLayout = new QHBoxLayout;
QVBoxLayout *groupLayout = new QVBoxLayout;
groupLayout->addWidget(monthRadioButton);
groupLayout->addWidget(yearRadioButton);
groupLayout->addWidget(noneRadioButton);

QVBoxLayout *sortValueLayout = new QVBoxLayout;
sortValueLayout->addWidget(dateCompletedRadioButton);
sortValueLayout->addWidget(dateStartedRadioButton);
archiveGroupLayout->addLayout(groupLayout);
archiveGroupLayout->addLayout(sortValueLayout);
generalTabLayout->addLayout(archiveGroupLayout);


generalTab->setLayout(generalTabLayout);
}
void OptionsDialog::layoutProjectsTab()
{
QFormLayout *optionsLayout = new QFormLayout;
optionsLayout->addRow(drawTitleCheckBox);
optionsLayout->addRow(titleLabel, titleLineEdit);
optionsLayout->addRow(titleColorLabel, titleColorBox);

QHBoxLayout *titleFontLayout = new QHBoxLayout;
titleFontLayout->addWidget(titleFontLineEdit);
titleFontLayout->addWidget(titleFontButton);

optionsLayout->addRow(titleFontLabel, titleFontLayout);
optionsLayout->addRow(drawYAxisTitleCheckBox);
optionsLayout->addRow(bgColorLabel, bgColorBox);
optionsLayout->addRow(barColorLabel);
optionsLayout->addRow(barColorComboBox);
optionsLayout->addRow(solidBarColorLabel, barColorBox);
optionsLayout->addRow(lowBarColorLabel, lowBarColorBox);
optionsLayout->addRow(highBarColorLabel, highBarColorBox);

QHBoxLayout *projectsTabLayout = new QHBoxLayout;
projectsTabLayout->addWidget(projectsListWidget);
projectsTabLayout->addSpacerItem(
new QSpacerItem(20, 0, QSizePolicy::Fixed));
projectsTabLayout->addLayout(optionsLayout, 1);

projectsTab->setLayout(projectsTabLayout);
}

void OptionsDialog::setSettings(BarGraphSettings &settings)
{
settings.setBarColorType(Solid);
settings.setBgColor(defaultBgColor);
settings.setHighBarColor(defaultHighBarColor);
settings.setLowBarColor(defaultLowBarColor);
settings.setSolidBarColor(defaultSolidBarColor);
settings.setTitle("");
settings.setTitleColor(defaultTitleColor);
settings.setTitleFont(defaultTitleFont);
}

void OptionsDialog::saveSettings(BarGraphSettings &settings)
{
// Store the current values of the widgets in settings
settings.setBarColorType(barColorType());
settings.setBgColor(backgroundColor());
settings.setHighBarColor(highColor());
settings.setLowBarColor(lowColor());
settings.setSolidBarColor(solidColor());
settings.setTitle(title());
settings.setTitleColor(titleColor());
settings.setTitleFont(titleFont());
settings.drawTitle(drawingTitle());
settings.drawYAxisTitle(drawingYAxisTitle());
}
void OptionsDialog::loadSettings(BarGraphSettings settings)
{
// Load the values from settings onto the widgets
drawTitleCheckBox->setChecked(settings.drawingTitle());
titleLineEdit->setText(tr("%1").arg(settings.title()));
titleColorBox->setColor(settings.titleColor());
titleFontLineEdit->setText(tr("%1").arg(settings.titleFont().toString()));
drawYAxisTitleCheckBox->setChecked(settings.drawingYAxisTitle());
barColorComboBox->setCurrentIndex(settings.barColorType());
bgColorBox->setColor(settings.bgColor());
barColorBox->setColor(settings.solidBarColor());
lowBarColorBox->setColor(settings.lowBarColor());
highBarColorBox->setColor(settings.highBarColor());
}
///////////////////////////////////////////


/////////////////////////
BarGraphSettings Header
/////////////////////////

#ifndef BARGRAPHSETTINGS_H
#define BARGRAPHSETTINGS_H

#include "optionsdialog.h"
class QColor;
class QFont;

class BarGraphSettings
{
public:
BarGraphSettings();
BarGraphSettings(QColor bgColor, QColor barColor, QColor titleColor, QFont titleFont);
BarGraphSettings(QColor bgColor, QColor lowBarColor, QColor highBarColor, QColor titleColor, QFont titleFont);

BarGraphSettings &operator=(const BarGraphSettings &settings);
bool operator==(const BarGraphSettings &settings) const;
bool operator!=(const BarGraphSettings &settings) const;

void setBarColorType(OptionsDialog::BarColorType type)
{ myBarColorType = type; }
void drawTitle(bool draw)
{ myDrawTitle = draw; }
void drawYAxisTitle(bool draw)
{ myDrawYAxisTitle = draw; }
void setBgColor(QColor color)
{ myBgColor = color; }
void setSolidBarColor(QColor color)
{ mySolidBarColor = color; }
void setLowBarColor(QColor color)
{ myLowBarColor = color; }
void setHighBarColor(QColor color)
{ myHighBarColor = color; }
void setTitle(QString title)
{ myTitle = title; }
void setTitleColor(QColor color)
{ myTitleColor = color; }
void setTitleFont(QFont font)
{ myTitleFont = font; }

OptionsDialog::BarColorType barColorType() const
{ return myBarColorType; }
bool drawingTitle() const
{ return myDrawTitle; }
bool drawingYAxisTitle() const
{ return myDrawYAxisTitle; }
QColor bgColor() const
{ return myBgColor; }
QColor solidBarColor() const
{ return mySolidBarColor; }
QColor lowBarColor() const
{ return myLowBarColor; }
QColor highBarColor() const
{ return myHighBarColor; }
QString title() const
{ return myTitle; }
QColor titleColor() const
{ return myTitleColor; }
QFont titleFont() const
{ return myTitleFont; }

private:
OptionsDialog::BarColorType myBarColorType;

bool myDrawTitle;
bool myDrawYAxisTitle;
QColor myBgColor;
QColor mySolidBarColor;
QColor myLowBarColor;
QColor myHighBarColor;
QString myTitle;
QColor myTitleColor;
QFont myTitleFont;
};
QDataStream &operator<<(QDataStream &out, const BarGraphSettings &settings);
QDataStream &operator>>(QDataStream &in, BarGraphSettings &settings);

#endif
///////////////////////////////////////////////////


////////////////////////
BarGraphSettings Source
///////////////////////

#include "bargraphsettings.h"
//
// Public Functions
//
BarGraphSettings::BarGraphSettings()
{
setBarColorType(OptionsDialog::Solid);
}
BarGraphSettings::BarGraphSettings(QColor bgColor, QColor barColor, QColor titleColor, QFont titleFont)
{
setBarColorType(OptionsDialog::Solid);
setBgColor(bgColor);
setSolidBarColor(barColor);
setTitleColor(titleColor);
setTitleFont(titleFont);

}
BarGraphSettings::BarGraphSettings(QColor bgColor, QColor lowBarColor, QColor highBarColor, QColor titleColor, QFont titleFont)
{
setBarColorType(OptionsDialog::Gradient);
setBgColor(bgColor);
setLowBarColor(lowBarColor);
setHighBarColor(highBarColor);
setTitleColor(titleColor);
setTitleFont(titleFont);
}

BarGraphSettings &BarGraphSettings::operator=(BarGraphSettings &settings)
{
setBarColorType(settings.barColorType());
drawTitle(settings.drawingTitle());
setDrawYAxisTitle(settings.drawingYAxisTitle());
setBgColor(settings.bgColor());
setSolidBarColor(settings.solidBarColor());
setLowBarColor(settings.lowBarColor());
setHighBarColor(settings.highBarColor());
setTitle(settings.title());
setTitleColor(settings.titleColor());
setTitleFont(settings.titleFont());

return settings;
}
bool BarGraphSettings::operator==(const BarGraphSettings &settings) const
{
if (barColorType() != settings.barColorType())
return false;
if (drawingTitle() != settings.drawingTitle())
return false;
if (drawingYAxisTitle() != settings.drawingYAxisTitle())
return false;
if (bgColor() != settings.bgColor())
return false;
if (solidBarColor() != settings.solidBarColor())
return false;
if (lowBarColor() != settings.lowBarColor())
return false;
if (highBarColor() != settings.highBarColor())
return false;
if (title() != settings.title())
return false;
if (titleColor() != settings.titleColor())
return false;
if (titleFont() != settings.titleFont())
return false;
return true;
}
bool BarGraphSettings::operator!=(const BarGraphSettings &settings) const
{
return !(*this == settings);
}


//
// QDataStream IO
//
QDataStream &operator<<(QDataStream &out, const BarGraphSettings &settings)
{
out << settings.drawingTitle() << settings.drawingYAxisTitle()
<< settings.bgColor() << settings.solidBarColor()
<< settings.lowBarColor() << settings.highBarColor()
<< settings.title() << settings.titleColor() << settings.titleFont()
<< quint16(settings.barColorType());
return out;
}
QDataStream &operator>>(QDataStream &in, BarGraphSettings &settings)
{
bool sDrawTitle;
bool sDrawYAxisTitle;
QColor sBgColor;
QColor sSolidBarColor;
QColor sLowBarColor;
QColor sHighBarColor;
QString sTitle;
QColor sTitleColor;
QFont sTitleFont;
quint16 sBarColorTypeInt;

in >> sDrawTitle >> sDrawYAxisTitle >> sBgColor >> sSolidBarColor
>> sLowBarColor >> sHighBarColor >> sTitle >> sTitleColor >> sTitleFont
>> sBarColorTypeInt;

OptionsDialog::BarColorType sBarColorType;
if (sBarColorTypeInt == OptionsDialog::Solid)
sBarColorType = OptionsDialog::Solid;
else
sBarColorType = OptionsDialog::Gradient;

settings.drawTitle(sDrawTitle);
settings.drawYAxisTitle(sDrawYAxisTitle);
settings.setBgColor(sBgColor);
settings.setSolidBarColor(sSolidBarColor);
settings.setLowBarColor(sLowBarColor);
settings.setHighBarColor(sHighBarColor);
settings.setTitle(sTitle);
settings.setTitleColor(sTitleColor);
settings.setTitleFont(sTitleFont);
settings.setBarColorType(sBarColorType);

return in;
}
////////////////////////////////////////////////////////

2

Saturday, July 3rd 2010, 6:51pm

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef OPTIONSDIALOG_H
#define OPTIONSDIALOG_H

#include <QDialog>
#include <QCheckBox>
#include <QLineEdit>
#include <QListWidgetItem>
#include "colorbox.h" 
class QTabWidget;
class QComboBox;
class QLabel;
class QListWidget;
class QListWidgetItem;
class QRadioButton;
class BarGraphSettings; // only declares that there is such still undefined class therefore pointers and references (?) are OK.
// instead of class Bar... use
#include "bargraphsettings.h"

class OptionsDialog : public QDialog
{
Q_OBJECT

public:
enum BarColorType { Solid, Gradient };

OptionsDialog(QWidget *parent = 0);

void setCurrentProjectSettings(BarGraphSettings settings);
void setNewProjectsSettings(BarGraphSettings settings);

bool isCurrentProjectSelected() const
{ return currentProjectItem->isSelected(); }
bool isNewProjectsSelected() const
{ return newProjectsItem->isSelected(); }

bool drawingTitle() const
{ return drawTitleCheckBox->isChecked(); }
bool drawingYAxisTitle() const
{ return drawYAxisTitleCheckBox->isChecked(); }

QString title() const
{ return titleLineEdit->text(); }
QColor titleColor() const
{ return titleColorBox->color(); }
QFont titleFont() const;

QColor backgroundColor() const
{ return bgColorBox->color(); }

BarColorType barColorType() const;
QColor solidColor() const
{ return barColorBox->color(); }
QColor lowColor() const
{ return lowBarColorBox->color(); }
QColor highColor() const
{ return highBarColorBox->color(); }

BarGraphSettings currentProjectSettings() const // class must be "fully known" at this time because class instance is returned (not pointer or reference).
{ return myCurrentProjectSettings; }
BarGraphSettings newProjectsSettings() const
{ return myNewProjectsSettings; }
Fighting fire with fire.
Three can keep a secret if two of them are dead.

3

Sunday, July 4th 2010, 10:23am

Okay, thanks. I never realized that difference.
I changed the top of optionsdialog.h so it looks like this.


#ifndef OPTIONSDIALOG_H
#define OPTIONSDIALOG_H

#include <QDialog>
#include <QCheckBox>
#include <QLineEdit>
#include <QListWidgetItem>
#include "colorbox.h"
#include "bargraphsettings.h"
class QTabWidget;
class QComboBox;
class QLabel;
class QListWidget;
class QListWidgetItem;
class QRadioButton;

but it still results in errors.
" 'BarGraphSettings' has not been declared"
and " 'BarGraphSettings' does not name a type"

4

Sunday, July 4th 2010, 11:07am

"bargraphsettings.h" includes "optionsdialog.h" and "optionsdialog.h" includes "bargraphsettings.h". Preprocessor guards will "cut out" (not include) the class (think like the preprocessor do).
Try to redesign.
Something like.
OptionsDialog::BarColorType BarColorType could be defined/introduced in the BarGraphSettings class or maybe even in BarGraph class or maybe in some global namespace (just like Qt::[Whatever])?
Then there will not be need to include "optionsdialog.h" in "bargraphsettings.h".
Fighting fire with fire.
Three can keep a secret if two of them are dead.

5

Sunday, July 4th 2010, 7:15pm

Thanks! I did what you said and it works fine now.