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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 34
Registered: ‎01-13-2013
My Device: BlackBerry Classic
My Carrier: O2 CZ
Accepted Solution

unknown ArrayDataModel

[ Edited ]

Hi, I am new to cascades and native development and have problems with development.

 

I wanted to use ArrayDataModel in my class but compiler do not know anything about ArrayDataModel:

 

#include <bb/cascades/ArrayDataModel>

..

private:

ArrayDataModel *model;

 

Compiler:

qcc -Vgcc_ntox86 -c -Wc,-include -Wc,o-g/.obj/ListTest -Wno-psabi -lang-c++ -fstack-protector-strong -g -Wno-psabi -Wall -W -D_REENTRANT -DQT_NO_IMPORT_QT47_QML -DQ_OS_BLACKBERRY -DQT_DECLARATIVE_DEBUG -DQT_DECLARATIVE_LIB -DQT_CORE_LIB -DQT_SHARED -I/Applications/bbndk/target_10_0_9_1673/qnx6/usr/share/qt4/mkspecs/blackberry-x86-qcc -I../../ListTest -I/Applications/bbndk/target_10_0_9_1673/qnx6/usr/include/qt4/QtCore -I/Applications/bbndk/target_10_0_9_1673/qnx6/usr/include/qt4/QtDeclarative -I/Applications/bbndk/target_10_0_9_1673/qnx6/usr/include/qt4 -I../src -Io-g/.moc -I/Applications/bbndk/target_10_0_9_1673/qnx6/usr/include -I/Applications/bbndk/target_10_0_9_1673/qnx6/usr/include/freetype2 -I. -o o-g/.obj/ListTest.o ../src/ListTest.cpp In file included from ../src/ListTest.cpp:8:0: ../src/Model.hpp:21:2: error: 'ArrayDataModel' does not name a type

 

../src/Model.hpp:29:2: error: 'ArrayDataModel' does not name a type

 

Can anyone point me to the solution of the problem please?

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: unknown ArrayDataModel

[ Edited ]

Try the following steps:

1) Remove #include <bb/cascades/ArrayDataModel> from .h file

2) In .h file forward-declare the class like this:

namespace bb
{
  namespace cascades
  {
    class ArrayDataModel;
  }
}

 

3)
Use fully-qualified names in header files:

private:
  bb::cascades::ArrayDataModel *model;

 

4) In C++ file add:

#include <bb/cascades/ArrayDataModel>

using namespace bb::cascades;


Andrey Fidrya, @zmeyc on twitter
Highlighted
Developer
Posts: 34
Registered: ‎01-13-2013
My Device: BlackBerry Classic
My Carrier: O2 CZ

Re: unknown ArrayDataModel

Thanks a lot. It worked.

I have just one question - why it is not working just with import?

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: unknown ArrayDataModel

Cascades classes reside in bb::cascades namespace. So it would work if you used fully-qualified name or added "using namespace bb::cascades". But the steps above is the recommended way to design C++ classes.

 

It's not recommended to call "using namespace" in .h files: namespaces exist to resolve potential naming conflicts and this will pollute namespace of every .cpp file which includes such header file.

 

#include directive in C++ simply inserts the text of specified file during preprocessing stage. So you can include things in ".h" files, but this will slow down the compilation as every .cpp file which uses the header will get a copy of all included headers even if it doesn't need them.

 

So it's generally recommended to keep the number of #include-s minimal and to forward-declare classes in .h files.

 #include them only in .cpp where they are used.

 

 

Complete class definition is required when the class is instantiated, for example:

 

SomeClass t;   // #include is required

 

When a pointer or a reference is declared, forward declaration is enough:

 

SomeClass *t; // no need to #include the header

SomeClass &t; //  no need to #include the header

 

t = new SomeClass; // instantiation, #include is required

 

Complete class definition is also required when inheriting from classes:

 

class X: public Y  // #include <Y> is required

{ ... }

 


Andrey Fidrya, @zmeyc on twitter