Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
silwar
Posts: 53
Registered: ‎01-12-2011
My Device: BOLD 9780
My Carrier: Bharti Airtel
Accepted Solution

'Page' does not name a type issue with Code given

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?

Please use plain text.
Developer
oliver_kranz
Posts: 216
Registered: ‎09-18-2009
My Device: Z10
My Carrier: O2

Re: 'Page' does not name a type issue with Code given

Do you have all the includes?

 

#include <bb/cascades/Page>

 

Please use plain text.
Developer
silwar
Posts: 53
Registered: ‎01-12-2011
My Device: BOLD 9780
My Carrier: Bharti Airtel

Re: 'Page' does not name a type issue with Code given

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_ */

Please use plain text.
Developer
silwar
Posts: 53
Registered: ‎01-12-2011
My Device: BOLD 9780
My Carrier: Bharti Airtel

Re: 'Page' does not name a type issue with Code given

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;

};

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: 'Page' does not name a type issue with Code given

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)

 

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.