View Full Version : [SOLVED] Widget plugin ... Problem with enumeration

30th January 2006, 16:41

I'm writing a new widget and I have some issu that I don't understand.

The aim of that widget is to configure a sound object. This class has some parameters and at least two properties (PlayMode and RestitutionMode) recorded in two variables which type is an enumeration.

My problem is in the functions that returns the value of those two variables. In my opinion the syntax is correct but the compilation failes so maybe it's due to something else that is linked with Q_ENUMS or Q_PROPERTY, I hope someone will be able to help me.

He are my questions :
What is wrong with my code ?
* The compilation errors I got are the following

./SoundConfigurator.cpp(122) C2143 : syntax error, missing ";" before 'tag::id'

./SoundConfigurator.cpp(122) C2501 : 'PlayMode' : missing storage class or type specifiers

* What is the use of Q_ENUMS and Q_PROPERTY ? (I read the documentation but the index does not find any entries for Q_ENUMS and Q_PROPERTY)

Thansk in advance

30th January 2006, 16:45
hoops, I forgot a question.

In a close future my class will be integrated into a plugin and will also have a member of type CFileChooser which is also a plugin I had Developped.

Do I need to do something special to add a CFileChooser member into (other than adding a #include directive) ?

Do I need to do something special into the plugin.h of my CSoundConfigurator to declare the CFileChooser plugin member ?


30th January 2006, 20:23
hum, no one could help me ?

30th January 2006, 21:00
The compilation errors I got are the following
Could you post the relevant part of your code?

What is the use of Q_ENUMS and Q_PROPERTY ? (I read the documentation but the index does not find any entries for Q_ENUMS and Q_PROPERTY)

2nd February 2006, 10:16
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)
:QWidget(parent, name)
// ... for main layout
QVBoxLayout* mainLayout = new QVBoxLayout(this);

// ... for the widget title
widgetTitleLabel = new QLabel("SOUND PARAM", this, "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);

// ... 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);

// ... signal to slot management
connect(soundPlayModeComboBox,SIGNAL(activated (int)),this, SLOT(processSoundPlayModeChange(PlayMode)));
connect(soundRestitutionModeComboBox,SIGNAL(activa ted(int)),this, SLOT(processSoundRestitutionModeChange(Restitution Mode)));

// Slots
void CSoundConfigurator::processSoundPlayModeChange(Pla yMode value)
// Process something specific ... eventually
// TO DO

// Emit the signal
emit soundPlayModeChanged(value);

void CSoundConfigurator::processSoundRestitutionModeCha nge(RestitutionMode value)
// Process something specific ... eventually
// TO DO

// Emit the signal
emit soundRestitutionModeChanged(value);

void CSoundConfigurator::setSoundPlayModeTitle(const QString& value)

void CSoundConfigurator::setSoundPlayModeValue(PlayMode value)

void CSoundConfigurator::setSoundRestitutionModeTitle(c onst QString& value)

void CSoundConfigurator::setSoundRestitutionModeValue(R estitutionMode 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();

The .h


#include <qwidget.h>

class QLabel;
class QComboBox;

class CSoundConfigurator : public QWidget

enum PlayMode {Single=0, Loop=1};
enum RestitutionMode {AllHp=0, NoHp=1};

// Constructor / Destructor
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
void soundPlayModeChanged (PlayMode);
void soundRestitutionModeChanged (RestitutionMode);

// Functions
QString getSoundPlayModeTitle () const;
PlayMode getSoundPlayModeValue () const;

QString getSounfRestitutionTitle () const;
RestitutionMode getSoundResitutionValue () const;

// Members
QLabel* soundPlayModeLabel;
QComboBox* soundPlayModeComboBox;

QLabel* soundRestitutionModeLabel;
QComboBox* soundRestitutionModeComboBox;


The main.cpp

#include <qapplication.h>
#include "soundconfigurator.h"

int main(int argc, char** argv)
QApplication a(argc, argv);

CSoundConfigurator* sc = new CSoundConfigurator();

return a.exec();

My errors are the following

error C2143: syntax error: missing ';' before 'tag::id" This error occurs in the function
PlayMode CSoundConfigurator::getSoundPlayModeValue() const
return soundPlayModeComboBox->currentItem();

error C2501: 'PlayMode' : missing storage class or type specifiers This error occurs in the same line as the previous one

fatal error C1004: unexpected end of file found ... still the same line

2nd February 2006, 15:59
CSoundConfigurator::PlayMode CSoundConfigurator::getSoundPlayModeValue() const
return soundPlayModeComboBox->currentItem();

3rd February 2006, 10:13
Ok, thanks, I will try this week end give you a a final reply (I hope so) on monday morning.

3rd February 2006, 11:20

Thanks jacek, it works.