02-07-2013 03:10 AM
Hi,
I am trying code given in this page but I am getting 'Page' does not name a type in Test.hpp file at following line
private:
Page *appPage;
Container *mRootContainer;
};
What could be the possible solution for resolving this issue?
Solved! Go to Solution.
02-07-2013 03:17 AM
Do you have all the includes?
#include <bb/cascades/Page>
02-07-2013 03:35 AM
Yes I have added all include
// Default empty project template
#ifndef ContainerInjection_HPP_
#define ContainerInjection_HPP_
#include<QObject>
#include<bb/cascades/Page>
#include<bb/cascades/Container>
namespace bb { namespace cascades { class Application; }}
classContainerInjection : publicQObject
{
Q_OBJECT
public:
ContainerInjection(bb::cascades::Application *app);
virtual ~ContainerInjection() {}
// By using Q_INVOKABLE we can call it from qml
Q_INVOKABLE void injectContainer();
private:
Page *appPage;
Container *mRootContainer;
};
#endif/* ContainerInjection_HPP_ */
02-07-2013 03:40 AM
Ok I have solved this issue with adding bb::cascades with page
please have a look at following code
private:
bb::cascades::Page *appPage;
bb::cascades::Container *mRootContainer;
};
02-07-2013 08:07 AM
Hi,
It's better to forward-declare classes in .h file just like the Application class is declared in your code:
namespace bb {
namespace cascades {
class Application;
class Container;
class Page;
}
}
This will make compilation faster, which is especially noticeable in large projects.
Include files in .cpp only if possible.
In .h files include:
1) QObject.h - this is required by MOC
2) Classes which are instantiated in place (for example MyClass c; not MyClass *c - this is just a pointer and doesn't require a fully defined class)
3) Class from which your class inherits (in this case it is QObject)