Results 1 to 6 of 6

Thread: strange QT error out of nowhere

  1. #1
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default strange QT error out of nowhere

    Hi!

    I was using QT 4.4 and Ogre3D 1.4.9 to create a level editor in visual studio 8. I was able to get an Ogre window up and running as a widget and got some more features working. However, this morning all of a sudden it started giving me some MOC errors on the Ogre widget cpp file out of nowhere. I retraced my steps and took out the new changes but the error did not seem to go away.

    Just for the heck of it, I started a project from scratch and pasted a fresh block of code (just to get basic ogre window up and running, this worked the last time) and I keep getting similar error. I checked the Ogre log and it is blank...which means Ogre never initialized at all.

    Here are the errors I am getting:

    1>------ Build started: Project: WorldBuilder, Configuration: Debug Win32 ------
    1>Moc'ing ogrewidget.h...
    1>Uic'ing d:\My Documents\Projects\Ogre3D\WorldBuilder\WorldBuilde r\worldbuilder.ui...
    1>Moc'ing worldbuilder.h...
    1>Compiling...
    1>main.cpp
    1>worldbuilder.cpp
    1>ogrewidget.cpp
    1>Generating Code...
    1>Compiling...
    1>moc_ogrewidget.cpp
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(37) : error C3083: 'OgreWidget': the symbol to the left of a '::' must be a type
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(37) : error C2039: 'staticMetaObject' : is not a member of 'Ogre'
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(42) : error C3083: 'OgreWidget': the symbol to the left of a '::' must be a type
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(42) : error C2039: 'metaObject' : is not a member of 'Ogre'
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(43) : error C2270: 'metaObject' : modifiers not allowed on nonmember functions
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(47) : error C3083: 'OgreWidget': the symbol to the left of a '::' must be a type
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(47) : error C2039: 'qt_metacast' : is not a member of 'Ogre'
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(51) : error C2673: 'qt_metacast' : global functions do not have 'this' pointers
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(52) : error C2352: 'QWidget::qt_metacast' : illegal call of non-static member function
    1> c:\qt\4.4.0\src\gui\kernel\qwidget.h(122) : see declaration of 'QWidget::qt_metacast'
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(55) : error C3083: 'OgreWidget': the symbol to the left of a '::' must be a type
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(55) : error C2039: 'qt_metacall' : is not a member of 'Ogre'
    1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(57) : error C2352: 'QWidget::qt_metacall' : illegal call of non-static member function
    1> c:\qt\4.4.0\src\gui\kernel\qwidget.h(122) : see declaration of 'QWidget::qt_metacall'
    1>Build log was saved at "file://d:\My Documents\Projects\Ogre3D\WorldBuilder\WorldBuilde r\Debug\BuildLog.htm"
    1>WorldBuilder - 12 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


    Here ar ethe only two files that I have added to the basic QT project: (then I created a widget in the .ui file and promoted it to OgreWidget)

    OgreWidget.h
    Qt Code:
    1. #ifndef OGREWIDGET_H_
    2. #define OGREWIDGET_H_
    3.  
    4. #include <QWidget>
    5.  
    6. #include <Ogre.h>
    7.  
    8. class OgreWidget : public QWidget
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. OgreWidget(QWidget* parent);
    14. ~OgreWidget();
    15.  
    16. protected:
    17. void paintEvent(QPaintEvent* evt);
    18. void resizeEvent(QResizeEvent* evt);
    19. void timerEvent(QTimerEvent* evt);
    20.  
    21. void refresh();
    22.  
    23. private:
    24. Ogre::Root* root;
    25. Ogre::SceneManager* sceneManager;
    26. Ogre::RenderWindow* window;
    27. Ogre::Camera* cam;
    28. };
    29.  
    30. #endif /*OGREWIDGET_H_*/
    To copy to clipboard, switch view to plain text mode 


    OgreWidget.cpp
    Qt Code:
    1. #include "ogrewidget.h"
    2.  
    3. #include <QMouseEvent>
    4.  
    5. OgreWidget::OgreWidget(QWidget* parent) : QWidget(parent, Qt::MSWindowsOwnDC)
    6. {
    7. setAttribute(Qt::WA_PaintOnScreen);
    8. setAttribute(Qt::WA_NoBackground);
    9.  
    10. root = 0;
    11. sceneManager = 0;
    12. window = 0;
    13. cam = 0;
    14. }
    15.  
    16. OgreWidget::~OgreWidget()
    17. {
    18. }
    19.  
    20. void OgreWidget::paintEvent(QPaintEvent* evt)
    21. {
    22. if(!window)
    23. {
    24. using namespace Ogre;
    25.  
    26. Ogre::NameValuePairList params;
    27. WId wid = winId();
    28. params["externalWindowHandle"] = Ogre::StringConverter::toString((size_t)wid);
    29.  
    30. // This doesn't actually work anymore. Look at the Qt Ogre model viewer for how to do this.
    31. #if !defined(Q_WS_WIN)
    32. char buf[64];
    33. sprintf(buf, "SDL_WINDOWID=0x%1x", wid);
    34. putenv(buf);
    35. #endif
    36.  
    37. root = new Ogre::Root();
    38.  
    39. root->loadPlugin("RenderSystem_GL_d");
    40.  
    41. Ogre::RenderSystemList *list = root->getAvailableRenderers();
    42. Ogre::RenderSystemList::iterator i = list->begin();
    43.  
    44. while (i != list->end())
    45. {
    46. if ((*i)->getName() == "OpenGL Rendering Subsystem")
    47. {
    48. root->setRenderSystem(*(i));
    49. break;
    50. }
    51.  
    52. i++;
    53. }
    54.  
    55. root->initialise(false);
    56.  
    57. window = root->createRenderWindow("OgreWindow", width(), height(), false, &params);
    58. sceneManager = root->createSceneManager(Ogre::ST_GENERIC);
    59.  
    60. ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    61.  
    62. cam = sceneManager->createCamera("Cam");
    63.  
    64. window->addViewport(cam)->setBackgroundColour(Ogre::ColourValue::Black);
    65.  
    66. cam->setPosition(0, 150, 100);
    67. cam->lookAt(0, 150, 0);
    68.  
    69. startTimer(60);
    70. }
    71.  
    72. refresh();
    73. }
    74.  
    75. void OgreWidget::resizeEvent(QResizeEvent* evt)
    76. {
    77. if(window)
    78. {
    79. window->resize(width(), height());
    80. window->windowMovedOrResized();
    81. cam->setAspectRatio(Ogre::Real(window->getViewport(0)->getActualWidth()) / Ogre::Real(window->getViewport(0)->getActualHeight()));
    82. }
    83. }
    84.  
    85. void OgreWidget::timerEvent(QTimerEvent* evt)
    86. {
    87. refresh();
    88. }
    89.  
    90. void OgreWidget::refresh()
    91. {
    92. Ogre::Root::getSingleton()._fireFrameStarted();
    93. window->update();
    94. Ogre::Root::getSingleton()._fireFrameEnded();
    95. }
    To copy to clipboard, switch view to plain text mode 


    contents of moc_ogrewidget.cpp
    Qt Code:
    1. /****************************************************************************
    2. ** Meta object code from reading C++ file 'ogrewidget.h'
    3. **
    4. ** Created: Tue Aug 12 02:00:54 2008
    5. ** by: The Qt Meta Object Compiler version 59 (Qt 4.4.0)
    6. **
    7. ** WARNING! All changes made in this file will be lost!
    8. *****************************************************************************/
    9.  
    10. #include "../../Source/ogrewidget.h"
    11. #if !defined(Q_MOC_OUTPUT_REVISION)
    12. #error "The header file 'ogrewidget.h' doesn't include <QObject>."
    13. #elif Q_MOC_OUTPUT_REVISION != 59
    14. #error "This file was generated using the moc from 4.4.0. It"
    15. #error "cannot be used with the include files from this version of Qt."
    16. #error "(The moc has changed too much.)"
    17. #endif
    18.  
    19. QT_BEGIN_MOC_NAMESPACE
    20. static const uint qt_meta_data_Ogre__OgreWidget[] = {
    21.  
    22. // content:
    23. 1, // revision
    24. 0, // classname
    25. 0, 0, // classinfo
    26. 0, 0, // methods
    27. 0, 0, // properties
    28. 0, 0, // enums/sets
    29.  
    30. 0 // eod
    31. };
    32.  
    33. static const char qt_meta_stringdata_Ogre__OgreWidget[] = {
    34. "Ogre::OgreWidget\0"
    35. };
    36.  
    37. const QMetaObject Ogre::OgreWidget::staticMetaObject = {
    38. { &QWidget::staticMetaObject, qt_meta_stringdata_Ogre__OgreWidget,
    39. qt_meta_data_Ogre__OgreWidget, 0 }
    40. };
    41.  
    42. const QMetaObject *Ogre::OgreWidget::metaObject() const
    43. {
    44. return &staticMetaObject;
    45. }
    46.  
    47. void *Ogre::OgreWidget::qt_metacast(const char *_clname)
    48. {
    49. if (!_clname) return 0;
    50. if (!strcmp(_clname, qt_meta_stringdata_Ogre__OgreWidget))
    51. return static_cast<void*>(const_cast< OgreWidget*>(this));
    52. return QWidget::qt_metacast(_clname);
    53. }
    54.  
    55. int Ogre::OgreWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
    56. {
    57. _id = QWidget::qt_metacall(_c, _id, _a);
    58. if (_id < 0)
    59. return _id;
    60. return _id;
    61. }
    62. QT_END_MOC_NAMESPACE
    To copy to clipboard, switch view to plain text mode 

    I'd greatly appreciate any help at all!

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

    Default Re: strange QT error out of nowhere

    Looks like the Ogre.h include failed. Check that it indeed gets included.
    Last edited by wysota; 12th August 2008 at 07:42. Reason: Changed contents

  3. The following user says thank you to wysota for this useful post:

    Penut (12th August 2008)

  4. #3
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: strange QT error out of nowhere

    Well I can open Ogre.h by right clicking on #include <Ogre.h>. Besides I have not made a change to that ever since I wrote it.

    I do not know any way of checking if the file was included until actually I have a window running of some sort. My program does not even compile now.

  5. #4
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: strange QT error out of nowhere

    Show your .pro file. Do you modify include path?
    I'm a rebel in the S.D.G.

  6. The following user says thank you to lyuts for this useful post:

    Penut (14th August 2008)

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

    Default Re: strange QT error out of nowhere

    Quote Originally Posted by Penut View Post
    Well I can open Ogre.h by right clicking on #include <Ogre.h>.
    It only means your Visual Studio can find the file, not that it is actually included in the build.

    I do not know any way of checking if the file was included until actually I have a window running of some sort.
    That's not very good You can enable some verbosity options for your compiler or something.

  8. The following user says thank you to wysota for this useful post:

    Penut (14th August 2008)

  9. #6
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: strange QT error out of nowhere

    turns out it was related to windows. a simple reboot solved it!

    But I've learned something from all this....#1 always reboot when there occurs a problem even after you didnt change anything since the last successful build.....and #2...the more important one is how to turn on the compiler feature to access debug variables without outputting them to a window

    thank you everyone for your replies

Similar Threads

  1. Very strange behavior of QWidget in Qt Designer
    By THRESHE in forum Qt Programming
    Replies: 10
    Last Post: 13th August 2008, 16:19
  2. Strange behavior with Drag and Drop (not always drops)
    By Mona Shokrof in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2007, 18:00
  3. Strange shortcut problem
    By blukske in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2007, 10:26
  4. very strange behaviour
    By regix in forum Qt Programming
    Replies: 23
    Last Post: 20th July 2006, 17:38
  5. QComboBox +SUSE10.0 +qt4.1 strange behavior
    By antonio.r.tome in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2006, 17:49

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.