Here is my code
The .cpp
#include "soundconfigurator.h"
#include <qlayout.h>
#include <qlabel.h>
#include <qcombobox.h>
CSoundConfigurator
::CSoundConfigurator(QWidget* parent,
const char* name
){
// ... for main layout
// ... for the widget title
widgetTitleLabel
= new QLabel("SOUND PARAM",
this,
"widgetTitleLabel");
mainLayout->addWidget(widgetTitleLabel);
// ... for play mode
soundPlayModeLabel
= new QLabel("PLAY MODE",
this,
"soundPlayModeLabel");
soundPlayModeComboBox
= new QComboBox(this,
"soundPlayModeComboBox");
soundPlayModeComboBox
->insertItem
(QString("Single"), PlayMode
::SingleShot);
soundPlayModeComboBox
->insertItem
(QString("Loop"), PlayMode
::Loop);
layoutPlayMode->addWidget(soundPlayModeLabel);
layoutPlayMode->addWidget(soundPlayModeComboBox);
// ... for restitution mode
soundRestitutionModeLabel
= new QLabel("Sound Restitution",
this,
"soundRestitutionModeLabel");
soundRestitutionModeComboBox
= new QComboBox(this,
"soundRestitutionModeComboBox");
soundRestitutionModeComboBox
->insertItem
(QString("All"), RestitutionMode
::AllHp);
soundRestitutionModeComboBox
->insertItem
(QString("None"), RestitutionMode
::NoHp);
layoutRestitutionMode->addWidget(soundRestitutionModeLabel);
layoutRestitutionMode->addWidget(soundRestitutionModeComboBox);
// ... signal to slot management
connect(soundPlayModeComboBox,SIGNAL(activated (int)),this, SLOT(processSoundPlayModeChange(PlayMode)));
connect(soundRestitutionModeComboBox,SIGNAL(activated(int)),this, SLOT(processSoundRestitutionModeChange(RestitutionMode)));
}
// Slots
void CSoundConfigurator::processSoundPlayModeChange(PlayMode value)
{
// Process something specific ... eventually
// TO DO
// Emit the signal
emit soundPlayModeChanged(value);
}
void CSoundConfigurator::processSoundRestitutionModeChange(RestitutionMode value)
{
// Process something specific ... eventually
// TO DO
// Emit the signal
emit soundRestitutionModeChanged(value);
}
void CSoundConfigurator::setSoundPlayModeTitle(const QString& value)
{
soundPlayModeLabel->setText(value);
}
void CSoundConfigurator::setSoundPlayModeValue(PlayMode value)
{
soundPlayModeComboBox->setCurrentItem(value);
}
void CSoundConfigurator::setSoundRestitutionModeTitle(const QString& value)
{
soundRestitutionModeLabel->setText(value);
}
void CSoundConfigurator::setSoundRestitutionModeValue(RestitutionMode value)
{
soundRestitutionModeComboBox->setCurrentItem(value);
}
// Functions
QString CSoundConfigurator
::getSoundPlayModeTitle() const {
return soundPlayModeLabel->text();
}
PlayMode CSoundConfigurator::getSoundPlayModeValue() const
{
return soundPlayModeComboBox->currentItem();
}
QString CSoundConfigurator
::getSounfRestitutionTitle() const {
return soundRestitutionModeLabel->text();
}
RestitutionMode CSoundConfigurator::getSoundResitutionValue() const
{
return soundRestitutionModeComboBox->currentItem();
}
#include "soundconfigurator.h"
#include <qlayout.h>
#include <qlabel.h>
#include <qcombobox.h>
CSoundConfigurator::CSoundConfigurator(QWidget* parent, const char* name)
:QWidget(parent, name)
{
// ... for main layout
QVBoxLayout* mainLayout = new QVBoxLayout(this);
// ... for the widget title
widgetTitleLabel = new QLabel("SOUND PARAM", this, "widgetTitleLabel");
mainLayout->addWidget(widgetTitleLabel);
// ... for play mode
QHBoxLayout* layoutPlayMode = new QHBoxLayout(mainLayout);
soundPlayModeLabel = new QLabel("PLAY MODE", this, "soundPlayModeLabel");
soundPlayModeComboBox = new QComboBox(this, "soundPlayModeComboBox");
soundPlayModeComboBox->insertItem(QString("Single"), PlayMode::SingleShot);
soundPlayModeComboBox->insertItem(QString("Loop"), PlayMode::Loop);
layoutPlayMode->addWidget(soundPlayModeLabel);
layoutPlayMode->addWidget(soundPlayModeComboBox);
// ... for restitution mode
QHBoxLayout* layoutRestitutionMode = new QHBoxLayout(mainLayout);
soundRestitutionModeLabel = new QLabel("Sound Restitution", this, "soundRestitutionModeLabel");
soundRestitutionModeComboBox = new QComboBox(this, "soundRestitutionModeComboBox");
soundRestitutionModeComboBox->insertItem(QString("All"), RestitutionMode::AllHp);
soundRestitutionModeComboBox->insertItem(QString("None"), RestitutionMode::NoHp);
layoutRestitutionMode->addWidget(soundRestitutionModeLabel);
layoutRestitutionMode->addWidget(soundRestitutionModeComboBox);
// ... signal to slot management
connect(soundPlayModeComboBox,SIGNAL(activated (int)),this, SLOT(processSoundPlayModeChange(PlayMode)));
connect(soundRestitutionModeComboBox,SIGNAL(activated(int)),this, SLOT(processSoundRestitutionModeChange(RestitutionMode)));
}
// Slots
void CSoundConfigurator::processSoundPlayModeChange(PlayMode value)
{
// Process something specific ... eventually
// TO DO
// Emit the signal
emit soundPlayModeChanged(value);
}
void CSoundConfigurator::processSoundRestitutionModeChange(RestitutionMode value)
{
// Process something specific ... eventually
// TO DO
// Emit the signal
emit soundRestitutionModeChanged(value);
}
void CSoundConfigurator::setSoundPlayModeTitle(const QString& value)
{
soundPlayModeLabel->setText(value);
}
void CSoundConfigurator::setSoundPlayModeValue(PlayMode value)
{
soundPlayModeComboBox->setCurrentItem(value);
}
void CSoundConfigurator::setSoundRestitutionModeTitle(const QString& value)
{
soundRestitutionModeLabel->setText(value);
}
void CSoundConfigurator::setSoundRestitutionModeValue(RestitutionMode value)
{
soundRestitutionModeComboBox->setCurrentItem(value);
}
// Functions
QString CSoundConfigurator::getSoundPlayModeTitle() const
{
return soundPlayModeLabel->text();
}
PlayMode CSoundConfigurator::getSoundPlayModeValue() const
{
return soundPlayModeComboBox->currentItem();
}
QString CSoundConfigurator::getSounfRestitutionTitle() const
{
return soundRestitutionModeLabel->text();
}
RestitutionMode CSoundConfigurator::getSoundResitutionValue() const
{
return soundRestitutionModeComboBox->currentItem();
}
To copy to clipboard, switch view to plain text mode
The .h
#ifndef _SOUND_CONFIGURATOR_H
#define _SOUND_CONFIGURATOR_H
#include <qwidget.h>
class CSoundConfigurator
: public QWidget{
Q_OBJECT
public:
enum PlayMode {Single=0, Loop=1};
enum RestitutionMode {AllHp=0, NoHp=1};
// Constructor / Destructor
public:
CSoundConfigurator
(QWidget* parent
=0,
const char* name
=0);
// Slots
private slots:
void processSoundPlayModeChange (PlayMode);
void processSoundRestitutionModeChange (RestitutionMode);
public slots:
void setSoundPlayModeTitle (const QString&);
void setSoundPlayModeValue (PlayMode);
void setSoundRestitutionModeTitle (const QString&);
void setSoundRestitutionModeValue (RestitutionMode);
// Signals
signals:
void soundPlayModeChanged (PlayMode);
void soundRestitutionModeChanged (RestitutionMode);
// Functions
public:
QString getSoundPlayModeTitle
() const;
PlayMode getSoundPlayModeValue () const;
QString getSounfRestitutionTitle
() const;
RestitutionMode getSoundResitutionValue () const;
// Members
private:
QLabel* soundRestitutionModeLabel;
};
#endif
#ifndef _SOUND_CONFIGURATOR_H
#define _SOUND_CONFIGURATOR_H
#include <qwidget.h>
class QLabel;
class QComboBox;
class CSoundConfigurator : public QWidget
{
Q_OBJECT
public:
enum PlayMode {Single=0, Loop=1};
enum RestitutionMode {AllHp=0, NoHp=1};
// Constructor / Destructor
public:
CSoundConfigurator(QWidget* parent=0, const char* name=0);
// Slots
private slots:
void processSoundPlayModeChange (PlayMode);
void processSoundRestitutionModeChange (RestitutionMode);
public slots:
void setSoundPlayModeTitle (const QString&);
void setSoundPlayModeValue (PlayMode);
void setSoundRestitutionModeTitle (const QString&);
void setSoundRestitutionModeValue (RestitutionMode);
// Signals
signals:
void soundPlayModeChanged (PlayMode);
void soundRestitutionModeChanged (RestitutionMode);
// Functions
public:
QString getSoundPlayModeTitle () const;
PlayMode getSoundPlayModeValue () const;
QString getSounfRestitutionTitle () const;
RestitutionMode getSoundResitutionValue () const;
// Members
private:
QLabel* soundPlayModeLabel;
QComboBox* soundPlayModeComboBox;
QLabel* soundRestitutionModeLabel;
QComboBox* soundRestitutionModeComboBox;
};
#endif
To copy to clipboard, switch view to plain text mode
The main.cpp
#include <qapplication.h>
#include "soundconfigurator.h"
int main(int argc, char** argv)
{
CSoundConfigurator* sc = new CSoundConfigurator();
a.setMainWidget(sc);
sc->show();
return a.exec();
}
#include <qapplication.h>
#include "soundconfigurator.h"
int main(int argc, char** argv)
{
QApplication a(argc, argv);
CSoundConfigurator* sc = new CSoundConfigurator();
a.setMainWidget(sc);
sc->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
My errors are the following
error C2143: syntax error: missing ';' before 'tag::id"
error C2143: syntax error: missing ';' before 'tag::id"
To copy to clipboard, switch view to plain text mode
This error occurs in the function
PlayMode CSoundConfigurator::getSoundPlayModeValue() const
{
return soundPlayModeComboBox->currentItem();
}
PlayMode CSoundConfigurator::getSoundPlayModeValue() const
{
return soundPlayModeComboBox->currentItem();
}
To copy to clipboard, switch view to plain text mode
error C2501: 'PlayMode' : missing storage class or type specifiers
error C2501: 'PlayMode' : missing storage class or type specifiers
To copy to clipboard, switch view to plain text mode
This error occurs in the same line as the previous one
fatal error C1004: unexpected end of file found
fatal error C1004: unexpected end of file found
To copy to clipboard, switch view to plain text mode
... still the same line
Bookmarks