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.

Reply
Retired
Posts: 150
Registered: ‎01-17-2012
My Device: BlackBerry Z10

Qt and C++

This thread is reserved for questions or comments relating to the "Qt and C++" online lesson and labs.

Contributor
Posts: 40
Registered: ‎07-23-2012
My Device: Z10 LE, Dev Alpha C

Re: Qt and C++

I solved the challenge question by adding:

 

objectName: "root"

 

...to the outer container in main.qml and:

 

    Container* container = root->findChild<Container*>("root");
    Q_ASSERT(container != NULL);
    container->add(Label::create("Hello Jaldhar!!!"));

...before setScene in the MyApp constructor.  Is this correct?  Because the wording seems to suggest  a label can be added directly to AbstractPane but I couldn't figure out how to make that work.

Contributor
Posts: 13
Registered: ‎04-02-2013
My Device: Z10

Re: Qt and C++

 

Well done.

I think that's a pretty good solution.

 

And, it is possible to add a label to the "abstract pane object" itself.

 

*SPOILER ALERT*

You have to reference it by its concrete type, a Page, instead of  AbstractPane, since there is no setContent function on AbstractPane itself.

Tricky. That's why it's a challenge. :-)

 

Contributor
Posts: 40
Registered: ‎07-23-2012
My Device: Z10 LE, Dev Alpha C

Re: Qt and C++

Thanks.  I had tried using Page but it doesn't have an add() method.  I didn't think to try setContent().  But this:

 

dynamic_cast<Page*>(root)->setContent(Label::create("Hello Jaldhar!!!"));

 

...definitely works.  The problem is now you only see the label.  I think the way I originally suggested is the only way to add the label to the existing layout am I right?

 

 

Contributor
Posts: 13
Registered: ‎04-02-2013
My Device: Z10

Re: Qt and C++

I don't know if that's the only way, but its the most salient one. I think you've got the idea now.
New Contributor
Posts: 6
Registered: ‎03-08-2014
My Device: Z10

Re: Qt and C++

I like the chalange solution stated above. 

I am still wondering how to find the documentation. 

I found myself pouring threw header files - Found how to create the label but was not able to determine how to add the label to the Page/Container/SubContainer - But thanks for the solution above.

 

 

New Contributor
Posts: 6
Registered: ‎03-08-2014
My Device: Z10

Re: Qt and C++

Well - that was easy - documentation is here: https://developer.blackberry.com/native/reference/cascades/

And I see that container->add will take ownership of the allocated label resource. 

 

 

Contributor
Posts: 20
Registered: ‎03-23-2014
My Device: Z10, Z30

Re: Qt and C++

So to start i am a newbie,

 

So with this lesson i get this error when adding this particular line #include<bb/cascacdes/Application> in MyApp.cpp

 

Multiple markers at this line

- Line breakpoint: MyApp.cpp [line: 10]

- Unresolved inclusion: <bb/cascacdes/Application>

- fatal error: bb/cascacdes/Application: No such file or 

directory

 

I'm following the lesson as i should. (I think! lol) i went through and double checked the code on the solutions package. 

 

i did a few more lessons past cause it says there are supposed to be issues with the compiling and thought it might get straigntened out after a lesson or two but now theres these errors in the main.cpp

 

multiple markers at this line

- 'appDelegate' has a previous declaration as 'MyApp* 

appDelegate'

- unused variable 'appDelegate' [-Wunused-variable] 

 

I just downloaded Momentics a few days ago. i'm using the global 10.2 SDK

 

New Contributor
Posts: 6
Registered: ‎03-08-2014
My Device: Z10

Re: Qt and C++

Well from one newbie to another:

 

The file should exist - so I would check your project settings.

Have you successfully built anything yet? 

 

Project->Properties

Select C/C++  General -> Paths and Symbols

 

Validate your settings for include directories. 

 

Now - I never had to set them. They were set somehow during the install I guess.

 

Have you tried creating a default app from scratch rather then copying the lesson as a starting point?

 

...Dale

 

New Contributor
Posts: 2
Registered: a week ago
My Device: Blackberry Z30

Re: Qt and C++

[ Edited ]

The below didn't fix anything... as it has clearly highlighted another problem that must of occured during the copy/import project process... Even though the application launches under the name of the new lab excersize, it appears to use none of the code or QML of the new project - as it appears exactly similar to the code of the previous project it was copied from :smileyfrustrated: ... Please ignore my solution below!

 



I ran into the same issue with the warnings with:

#include <QtCore/QObject> //Warning here

class MyApp : public QObject {
    Q_OBJECT //Warning here too

I too tried to copy the project as it suggested to do in the lab excersize, it was an un-godly process of uncertainty. However the fix for me was resolved with dcwood's suggestion plus one additional step

 

  1. (Alt+P) Project -> Properties
  2. C/C++ General -> Paths and Symbols
  3. Click "Restore Defaults" (it appears nothing happens, but i guess something does happen)
  4. Click "Apply"
  5. Click "Yes" to rebuild for the IDE

My warnings went away! but... I can't tell you why as the paths in this prompt all appear to be built in and dictated by a higher source, confused perhaps when copying said project. I think :smileyfrustrated: