Results 1 to 6 of 6

Thread: typedef question

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Red face typedef question

    I've added this line of code into a header file:
    Qt Code:
    1. //! new type declaration
    2. typedef QMap<QString, QVariant> settingsType;
    To copy to clipboard, switch view to plain text mode 
    and I get following errors:
    Qt Code:
    1. mingw32-make
    2. mingw32-make -f Makefile.Debug
    3. mingw32-make[1]: Entering directory `C:/Documents and Settings/markofr/workspace/SettingsEditor'
    4. c:\Qt\4.3.3\bin\uic.exe cmainwindow.ui -o ui_cmainwindow.h
    5. g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.3\include\QtCore" -I"..\..\..\..\Qt\4.3.3\include\QtCore" -I"..\..\..\..\Qt\4.3.3\include\QtGui" -I"..\..\..\..\Qt\4.3.3\include\QtGui" -I"..\..\..\..\Qt\4.3.3\include" -I"c:\Qt\4.3.3\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.3\mkspecs\win32-g++" -o debug\CApplicationSettings.o CApplicationSettings.cpp
    6. In file included from CApplicationSettings.h:11,
    7. from CApplicationSettings.cpp:1:
    8. setttingdefs.h:10: error: expected identifier before "typedef"
    9. setttingdefs.h:10: error: expected init-declarator before "settingsType"
    10. setttingdefs.h:10: error: expected `,' or `;' before "settingsType"
    11. In file included from CApplicationSettings.cpp:1:
    12. CApplicationSettings.h:28: error: `settingsType' does not name a type
    13. mingw32-make[1]: *** [debug/CApplicationSettings.o] Error 1
    14. mingw32-make[1]: Leaving directory `C:/Documents and Settings/markofr/workspace/SettingsEditor'
    15. mingw32-make: *** [debug] Error 2
    To copy to clipboard, switch view to plain text mode 

    Why typedef is not working??!!
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: typedef question

    You have an error earlier in your code, probably a missing semicolon after a class declaration.

  3. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: typedef question

    Well the only errors are found in header file CApplicationSettings.h:
    Qt Code:
    1. #ifndef CAPPLICATIONSETTINGS_H_
    2. #define CAPPLICATIONSETTINGS_H_
    3.  
    4. // qt includes
    5. #include <QSettings>
    6. #include <QMap>
    7. #include <QApplication>
    8.  
    9. // custom includes
    10. #include "globals.h"
    11. #include "setttingdefs.h"
    12.  
    13. /*!
    14.  * class responsible for whole EROSystem Settings
    15.  */
    16. class CApplicationSettings : public QSettings
    17. {
    18. Q_OBJECT
    19.  
    20. public:
    21. CApplicationSettings(QObject *pParent);
    22. ~CApplicationSettings();
    23. void addStringValue(QString strKey, QString strValue); // method for adding string value
    24. void addIntValue(QString strKey, qint16 iValue); // method for adding integer value
    25. void addFloatValue(QString strKey, qreal rValue); // method for adding real value
    26.  
    27. private:
    28. settingsType m_KeyedValues;
    29. };
    30.  
    31. #endif /*CAPPLICATIONSETTINGS_H_*/
    To copy to clipboard, switch view to plain text mode 
    in line 28 and then in file settingdefs.h:
    Qt Code:
    1. #ifndef SETTTINGDEFS_H_
    2. #define SETTTINGDEFS_H_
    3.  
    4. // qt includes
    5. #include <QObject>
    6. #include <QString>
    7. #include <QMap>
    8.  
    9. //! new type declaration
    10. typedef QMap<QString, QVariant> settingsType;
    11.  
    12. typedef struct structDBSettings
    13. {
    14. /*
    15.   QString strDBTypeValue(strdbType);
    16.   QString strDBHostValue(strdbHost);
    17.   QString strDBNameValue(strDatabaseName);
    18.   QString strDBUNameValue(strdbUserName);
    19.   QString strDBPassValue(strdbPassword);
    20. */
    21. QString strDBTypeValue();
    22. QString strDBHostValue();
    23. QString strDBNameValue();
    24. QString strDBUNameValue();
    25. QString strDBPassValue();
    26. }; // **** end of database key struct
    27.  
    28. /*!
    29.  * database settings keys
    30.  */
    31. //! database setttings main key
    32. QString strDBSettingsKey("Database Settings/");
    33. //! database type key
    34. QString strDBTypeKey("Database Type");
    35. //! database host key
    36. QString strDBHostKey("Database Host");
    37. //! database name key
    38. QString strDBName("Database Name");
    39. //! database access username key
    40. QString strDBUName("Username");
    41. //! database access password key
    42. QString strDBPass("Password");
    43. // **** end od database settings main key
    44.  
    45. #endif /*SETTTINGDEFS_H_*/
    To copy to clipboard, switch view to plain text mode 
    in line 10. And wysota, is this "design" of application settings class (i will reuse it in further projects, like my cdatabasefoundation class) ok or can you give me some useful hints?
    Qt 5.3 Opensource & Creator 3.1.2

  4. #4
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef question

    QVariant include is missing

  5. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: typedef question

    I've included it, same result, god damn, this must be some stupid mistake ...
    Qt 5.3 Opensource & Creator 3.1.2

  6. #6
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef question

    Ok, then something in global.h must be wrong

  7. The following user says thank you to ChristianEhrlicher for this useful post:

    MarkoSan (29th January 2008)

Similar Threads

  1. typedef Related doubts?
    By rajeshs in forum General Programming
    Replies: 3
    Last Post: 2nd January 2008, 19:05
  2. need for typedef Enum enum_type in qglobal.h
    By jamadagni in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2007, 17:56
  3. Access to QSqlTableModel::isDirty Question.
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 12th April 2007, 17:49
  4. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38

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
  •  
Qt is a trademark of The Qt Company.