PDA

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



yellowmat
30th January 2006, 15:41
Hi,

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

yellowmat
30th January 2006, 15: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 ?

Thanks

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

jacek
30th January 2006, 20: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)
http://doc.trolltech.com/3.3/properties.html

yellowmat
2nd February 2006, 09: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");
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(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)
{
soundPlayModeLabel->setText(value);
}


void CSoundConfigurator::setSoundPlayModeValue(PlayMode value)
{
soundPlayModeComboBox->setCurrentItem(value);
}


void CSoundConfigurator::setSoundRestitutionModeTitle(c onst QString& value)
{
soundRestitutionModeLabel->setText(value);
}


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


The .h

#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

The main.cpp

#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();
}

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

jacek
2nd February 2006, 14:59
Try:
CSoundConfigurator::PlayMode CSoundConfigurator::getSoundPlayModeValue() const
{
return soundPlayModeComboBox->currentItem();
}

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

yellowmat
3rd February 2006, 10:20
[SOLVED]

Thanks jacek, it works.