Results 1 to 8 of 8

Thread: [SOLVED] Widget plugin ... Problem with enumeration

  1. #1
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default [SOLVED] Widget plugin ... Problem with enumeration

    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
    Qt Code:
    1. ./SoundConfigurator.cpp(122) C2143 : syntax error, missing ";" before 'tag::id'
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. ./SoundConfigurator.cpp(122) C2501 : 'PlayMode' : missing storage class or type specifiers
    To copy to clipboard, switch view to plain text mode 

    * 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

  2. #2
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Widget plugin ... Problem with enumeration

    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

  3. #3
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Widget plugin ... Problem with enumeration

    hum, no one could help me ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Widget plugin ... Problem with enumeration

    Quote Originally Posted by yellowmat
    The compilation errors I got are the following
    Could you post the relevant part of your code?

    Quote Originally Posted by yellowmat
    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

  5. #5
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Widget plugin ... Problem with enumeration

    Here is my code

    The .cpp
    Qt Code:
    1. #include "soundconfigurator.h"
    2. #include <qlayout.h>
    3. #include <qlabel.h>
    4. #include <qcombobox.h>
    5.  
    6. CSoundConfigurator::CSoundConfigurator(QWidget* parent, const char* name)
    7. :QWidget(parent, name)
    8. {
    9. // ... for main layout
    10. QVBoxLayout* mainLayout = new QVBoxLayout(this);
    11.  
    12.  
    13. // ... for the widget title
    14. widgetTitleLabel = new QLabel("SOUND PARAM", this, "widgetTitleLabel");
    15. mainLayout->addWidget(widgetTitleLabel);
    16.  
    17.  
    18. // ... for play mode
    19. QHBoxLayout* layoutPlayMode = new QHBoxLayout(mainLayout);
    20. soundPlayModeLabel = new QLabel("PLAY MODE", this, "soundPlayModeLabel");
    21. soundPlayModeComboBox = new QComboBox(this, "soundPlayModeComboBox");
    22. soundPlayModeComboBox->insertItem(QString("Single"), PlayMode::SingleShot);
    23. soundPlayModeComboBox->insertItem(QString("Loop"), PlayMode::Loop);
    24. layoutPlayMode->addWidget(soundPlayModeLabel);
    25. layoutPlayMode->addWidget(soundPlayModeComboBox);
    26.  
    27.  
    28. // ... for restitution mode
    29. QHBoxLayout* layoutRestitutionMode = new QHBoxLayout(mainLayout);
    30. soundRestitutionModeLabel = new QLabel("Sound Restitution", this, "soundRestitutionModeLabel");
    31. soundRestitutionModeComboBox = new QComboBox(this, "soundRestitutionModeComboBox");
    32. soundRestitutionModeComboBox->insertItem(QString("All"), RestitutionMode::AllHp);
    33. soundRestitutionModeComboBox->insertItem(QString("None"), RestitutionMode::NoHp);
    34. layoutRestitutionMode->addWidget(soundRestitutionModeLabel);
    35. layoutRestitutionMode->addWidget(soundRestitutionModeComboBox);
    36.  
    37.  
    38. // ... signal to slot management
    39. connect(soundPlayModeComboBox,SIGNAL(activated (int)),this, SLOT(processSoundPlayModeChange(PlayMode)));
    40. connect(soundRestitutionModeComboBox,SIGNAL(activated(int)),this, SLOT(processSoundRestitutionModeChange(RestitutionMode)));
    41. }
    42.  
    43. // Slots
    44. void CSoundConfigurator::processSoundPlayModeChange(PlayMode value)
    45. {
    46. // Process something specific ... eventually
    47. // TO DO
    48.  
    49. // Emit the signal
    50. emit soundPlayModeChanged(value);
    51. }
    52.  
    53.  
    54. void CSoundConfigurator::processSoundRestitutionModeChange(RestitutionMode value)
    55. {
    56. // Process something specific ... eventually
    57. // TO DO
    58.  
    59. // Emit the signal
    60. emit soundRestitutionModeChanged(value);
    61. }
    62.  
    63.  
    64. void CSoundConfigurator::setSoundPlayModeTitle(const QString& value)
    65. {
    66. soundPlayModeLabel->setText(value);
    67. }
    68.  
    69.  
    70. void CSoundConfigurator::setSoundPlayModeValue(PlayMode value)
    71. {
    72. soundPlayModeComboBox->setCurrentItem(value);
    73. }
    74.  
    75.  
    76. void CSoundConfigurator::setSoundRestitutionModeTitle(const QString& value)
    77. {
    78. soundRestitutionModeLabel->setText(value);
    79. }
    80.  
    81.  
    82. void CSoundConfigurator::setSoundRestitutionModeValue(RestitutionMode value)
    83. {
    84. soundRestitutionModeComboBox->setCurrentItem(value);
    85. }
    86.  
    87.  
    88. // Functions
    89.  
    90.  
    91. QString CSoundConfigurator::getSoundPlayModeTitle() const
    92. {
    93. return soundPlayModeLabel->text();
    94. }
    95.  
    96.  
    97. PlayMode CSoundConfigurator::getSoundPlayModeValue() const
    98. {
    99. return soundPlayModeComboBox->currentItem();
    100. }
    101.  
    102.  
    103. QString CSoundConfigurator::getSounfRestitutionTitle() const
    104. {
    105. return soundRestitutionModeLabel->text();
    106. }
    107.  
    108.  
    109. RestitutionMode CSoundConfigurator::getSoundResitutionValue() const
    110. {
    111. return soundRestitutionModeComboBox->currentItem();
    112. }
    To copy to clipboard, switch view to plain text mode 

    The .h
    Qt Code:
    1. #ifndef _SOUND_CONFIGURATOR_H
    2. #define _SOUND_CONFIGURATOR_H
    3.  
    4. #include <qwidget.h>
    5.  
    6. class QLabel;
    7. class QComboBox;
    8.  
    9. class CSoundConfigurator : public QWidget
    10. {
    11. Q_OBJECT
    12.  
    13. public:
    14. enum PlayMode {Single=0, Loop=1};
    15. enum RestitutionMode {AllHp=0, NoHp=1};
    16.  
    17. // Constructor / Destructor
    18. public:
    19. CSoundConfigurator(QWidget* parent=0, const char* name=0);
    20.  
    21. // Slots
    22. private slots:
    23. void processSoundPlayModeChange (PlayMode);
    24. void processSoundRestitutionModeChange (RestitutionMode);
    25.  
    26. public slots:
    27. void setSoundPlayModeTitle (const QString&);
    28. void setSoundPlayModeValue (PlayMode);
    29.  
    30. void setSoundRestitutionModeTitle (const QString&);
    31. void setSoundRestitutionModeValue (RestitutionMode);
    32.  
    33. // Signals
    34. signals:
    35. void soundPlayModeChanged (PlayMode);
    36. void soundRestitutionModeChanged (RestitutionMode);
    37.  
    38. // Functions
    39. public:
    40. QString getSoundPlayModeTitle () const;
    41. PlayMode getSoundPlayModeValue () const;
    42.  
    43. QString getSounfRestitutionTitle () const;
    44. RestitutionMode getSoundResitutionValue () const;
    45.  
    46.  
    47. // Members
    48. private:
    49. QLabel* soundPlayModeLabel;
    50. QComboBox* soundPlayModeComboBox;
    51.  
    52. QLabel* soundRestitutionModeLabel;
    53. QComboBox* soundRestitutionModeComboBox;
    54. };
    55.  
    56. #endif
    To copy to clipboard, switch view to plain text mode 

    The main.cpp
    Qt Code:
    1. #include <qapplication.h>
    2. #include "soundconfigurator.h"
    3.  
    4. int main(int argc, char** argv)
    5. {
    6. QApplication a(argc, argv);
    7.  
    8. CSoundConfigurator* sc = new CSoundConfigurator();
    9. a.setMainWidget(sc);
    10. sc->show();
    11.  
    12. return a.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    My errors are the following
    Qt Code:
    1. error C2143: syntax error: missing ';' before 'tag::id"
    To copy to clipboard, switch view to plain text mode 
    This error occurs in the function
    Qt Code:
    1. PlayMode CSoundConfigurator::getSoundPlayModeValue() const
    2. {
    3. return soundPlayModeComboBox->currentItem();
    4. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. 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

    Qt Code:
    1. fatal error C1004: unexpected end of file found
    To copy to clipboard, switch view to plain text mode 
    ... still the same line

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Widget plugin ... Problem with enumeration

    Try:
    Qt Code:
    1. CSoundConfigurator::PlayMode CSoundConfigurator::getSoundPlayModeValue() const
    2. {
    3. return soundPlayModeComboBox->currentItem();
    4. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Widget plugin ... Problem with enumeration

    Ok, thanks, I will try this week end give you a a final reply (I hope so) on monday morning.

  8. #8
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Widget plugin ... Problem with enumeration

    [SOLVED]

    Thanks jacek, it works.

Similar Threads

  1. Problem with my own widget
    By Macok in forum Qt Programming
    Replies: 1
    Last Post: 24th January 2009, 23:38
  2. problem loading custom plugin on Qt Designer 4
    By raman_31181 in forum Qt Tools
    Replies: 18
    Last Post: 26th September 2008, 09:42
  3. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  4. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 19:05
  5. [SOLVED] Widget plugin ... how to ?
    By yellowmat in forum Newbie
    Replies: 10
    Last Post: 29th January 2006, 20:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.