[Solved] moc +boost::noncopyable namespace Probleme (QT4.1)

Alles rund um die Programmierung mit Qt
Antworten
QtBerserker
Beiträge: 71
Registriert: 15. Mai 2006 09:07

[Solved] moc +boost::noncopyable namespace Probleme (QT4.1)

Beitrag von QtBerserker »

das moc und namespace einige Probleme hat *1), habe ich nun schon nachlesen können, aber nun stehe ich ganz platt da:

Code: Alles auswählen

moc_application.cpp(56) : error C2039: 'qt_metacast': Ist kein Element von 'boost::noncopyable_::noncopyable'
        d:\boost-1_33_1\boost\noncopyable.hpp(22): Siehe Deklaration von 'boost::noncopyable_::noncopyable'
moc_application.cpp(61) : error C2039: 'qt_metacall': Ist kein Element von 'boost::noncopyable_::noncopyable'
        d:\boost-1_33_1\boost\noncopyable.hpp(22): Siehe Deklaration von 'boost::noncopyable_::noncopyable'
Offenbar bekommt er den namespace nicht gebacken, konkret schreibe ich:

Code: Alles auswählen

namespace eda {
  using boost::noncopyable;
}

namespace eda {
  class Application : public noncopyable, public QObject { Q_OBJECT ... };
}
importiere also boost in meinen namespace. Irgendeine Lösung/Hinweis?

moc macht daraus:

Code: Alles auswählen

void *Application::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_Application))
	return static_cast<void*>(const_cast<Application*>(this));
    if (!strcmp(_clname, "QApplication"))
	return static_cast<QApplication*>(const_cast<Application*>(this));
    return noncopyable::qt_metacast(_clname);
}

int Application::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = noncopyable::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: initialized(); break;
        }
        _id -= 1;
    }
    return _id;
}

*1) leider nimmt moc dieses:

Code: Alles auswählen

#define NS_BGN namespace eda {
nicht an; moc erlaubt den switch -Dfoo=bar, aber es hat nicht funtioniert (Qt4.1.2); btw gibt es eine QMAKE Variable dafür?


Viele Grüße
Olaf
Zuletzt geändert von QtBerserker am 13. Juni 2006 17:16, insgesamt 1-mal geändert.
QtBerserker
Beiträge: 71
Registriert: 15. Mai 2006 09:07

Beitrag von QtBerserker »

es scheint nunmehr kein spezifisches Problem von boost::noncopyable zu sein:

BoostOrg.hpp:

Code: Alles auswählen

  class noncopyable
  {
   protected:
      noncopyable() {}
      ~noncopyable() {}
   private:  // emphasize the following members are private
      noncopyable( const noncopyable& );
      const noncopyable& operator=( const noncopyable& );
  };

Code: Alles auswählen

class Application 
  : public noncopyable,
    public QApplication
{
  Q_OBJECT
	...
ergibt:

Code: Alles auswählen

...\moc_application.cpp(40) : error C2039: 'staticMetaObject': Ist kein Element von 'noncopyable'
...\moc_application.cpp(56) : error C2039: 'qt_metacast': Ist kein Element von 'noncopyable'
...\moc_application.cpp(61) : error C2039: 'qt_metacall': Ist kein Element von 'noncopyable'


mit moc_application.cpp:

Code: Alles auswählen

...
const QMetaObject Application::staticMetaObject = { // XXX LINE 40
    { &noncopyable::staticMetaObject, qt_meta_stringdata_Application,
      qt_meta_data_Application, 0 }
};
...
void *Application::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_Application))
	return static_cast<void*>(const_cast<Application*>(this));
    if (!strcmp(_clname, "QApplication"))
	return static_cast<QApplication*>(const_cast<Application*>(this));
    return noncopyable::qt_metacast(_clname); // XXX LINE 56
}
...
...
int Application::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = noncopyable::qt_metacall(_c, _id, _a); // XXX LINE 61
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: initialized(); break;
        }
        _id -= 1;
    }
    return _id;
}
was macht moc da?

Grüße
Olaf
Christian81
Beiträge: 7319
Registriert: 26. August 2004 14:11
Wohnort: Bremen
Kontaktdaten:

Beitrag von Christian81 »

Doku lesen :)
Multiple Inheritance Requires QObject to Be First

If you are using multiple inheritance, moc assumes that the first inherited class is a subclass of QObject. Also, be sure that only the first inherited class is a QObject.

// correct
class SomeClass : public QObject, public OtherClass
{
...
};

Virtual inheritance with QObject is not supported.
Sollte imho dein Problem sein, oder?
MfG Christian

'Funktioniert nicht' ist keine Fehlerbeschreibung
QtBerserker
Beiträge: 71
Registriert: 15. Mai 2006 09:07

Beitrag von QtBerserker »

wer lesen kann ist klar im Vorteil - danke!
Antworten