Assistance to access to the C++ class in QML

Hi all

Currently, I am having some problems of access to an object of class that is instantiated in C++, in my page QML.

First of all a little history on my app.  I create an application that enables users to register an account and then connect you on said account.  Account information is stored in a collection of Clouldbase.io that I can access by using their SDK BB10.  I have created a user class in my application that represent the users account and holds all the information I need from a user.  I create an instance of the class of user once different depending on whether the user is logged on or record.

My problem is that once the account is created for the first time or retrieved from cloudbase.io and the object user is all set up, I'm trying to display information to the user on a Page in my TabbedPane.  I have problems getting information from the C++ to display in QML.  I tried to register the type with QML, and of using Q_PROPERTY macro, but I always get "undefined" as my output.  If I put qDebug prints in my Set and Get functions attributed to the macro that the expected values are printed in the console, but for some reason any the QML does not get the value.  The information stored in the user class are mainly QString and integers (ints).

I also tried to use SetContextProperty but when I try to use it I get errors in the console on the 'client' is null.

Does anyone have any suggestions?  I apologize for not posting any code, but I am posting this at work and do not have access to my code.  I can publish code snippets later if necessary.

Thank you

Jared

Yep, this macro is critical for the property system work. Note that if you do not specify it before the first compilation of your class, then you will probably get vtable errors when you try to compile and link later after it is added. Easy (but non-obvious) solution for this is a trivial edit make .pro to your application file, such as adding a space then by removing and saving the file. This will force the GPM to re-evaluate all dynamic links and resolve properties, signals and slots on your class.

Zymatic wrote:

greenmr - thanks for the response.  I'll post the code real when I get home tonight, but of what I myself remember I certainly inherited from QObject, would the import statement in my QML.  I happened to have an older copy of the code with me here at work and it doesn't have the used Q_OBJECT macro, so maybe that's my problem.  I remember reading in the documentation that the macro has been necessary, but maybe I forgot to add it.  I'll check when I get home tonight.

Thank you

Tags: BlackBerry Developers

Similar Questions

  • Cannot access the template page links in the bean class

    Hi all

    I use JDEV 12 c.

    I have a model in which I have 2 languages English and Hindi.

    Change language (when), I have re - run LOV queries for the respective language.

    so I added links method in model pagedef and try to access the same thing in the bean model class.

    When I have access to, I get Nullpointer Exception, who says the OperationBinding, does not exist in pagedef.

    is there a any restriction I can't access model pagedef in the bean class.

    Please suggest on this.

    Thank you

    Vieira

    https://blogs.Oracle.com/jdevotnharvest/entry/how_to_invoke_adf_bindings

  • To access the methods of the VORowImpl class

    Scenario is,

    I have a view object class VOImpl.java in the model.view package.

    I have another class of JavaBean EntryHandle.java

    EntryHandle class I can Import model.view.VOImpl;

    Help me now how I can access methods of the VOImpl class in the ADF.

    Or I have to create the VOImpl object class in class EntryHandle? as in programming java Simple? or something else

    JDeveloper Version: 11g Release 2 11.1.2.0.0

    Zaid,

    If you have a VO with 2 attributes, you have defined the category value. (This poster Lov sense and sets the value for the category field).

    You want to get the value selected from the lov. Is this correct?

    When do you get this value? When they choose a new value from the LOV.

    If you have written the code in the valueChangeListener, you can check the link below:

    https://blogs.Oracle.com/ADF/entry/getting_selected_value_from_selectonechoice

    Code of the blog

    public void valueChanged(ValueChangeEvent valueChangeEvent) {
        this.setValueToEL("#{bindings.Deptno.inputValue}", valueChangeEvent.getNewValue()); //Updates the model
        System.out.println("\n******** Selected Value: "+resolveExpression("#{bindings.Deptno.attributeValue}"));
        System.out.println("\n******** Display Value: "+resolveExpression("#{bindings.Deptno.selectedValue ne ' ' ? bindings.Deptno.selectedValue.attributeValues[1] : ''}"));
    }
    
    public Object resolveExpression(String el) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory =  facesContext.getApplication().getExpressionFactory();
        ValueExpression valueExp = expressionFactory.createValueExpression(elContext,el,Object.class);
        return valueExp.getValue(elContext);
    }
    
    public void setValueToEL(String el, Object val) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory =   facesContext.getApplication().getExpressionFactory();
        ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
        exp.setValue(elContext, val);
    }
    

    You can get the selected value and the value of display with the above code. You need to replace Deptno by category.

    See you soon

    AJ

  • Access the function of the other class Document class

    I have this Enemy.as code that calls a function playerTurn() in Main.as, which is also the document class.

    var rootRef:Main;

    rootRef.playerTurn ();

    This is playerTurn()

    public void playerTurn(): void {}

    player_turn = true

    menu = battle_men

    menu.attackBtn.addEventListener (MouseEvent.CLICK, atkClicked);

    }

    After this code runs, I get

    TypeError: Error #1009: cannot access a property or method of a null object reference.

    at CharacterClasses::Enemy/initEnemyTurn() [C:\Users\***\Documents\SonicUltimateSceneCreat or\CharacterClasses\Enemy.as:23]

    Line 23 Enemy.as is rootRef.playerTurn ();

    Why I get this error?

    I got it.

    Object (parent) .playerTurn () worked well, but the function in which this line was performed was based on an event listener, as follows

    public void initEnemyTurn(evt:Event):void {}

    removeEventListener (Event.ENTER_FRAME, initEnemyTurn);

    player_turn = Main.player_turn;

    {if (player_turn)}

    addEventListener (Event.ENTER_FRAME, initEnemyTurn);

    }

    else {}

    Object (parent) .playerTurn ();

    }

    }

    initEnemyTurn is attached to an ENTER_FRAME listener, which was not readded in the else statement, thereby breaking the code.

    The reason why it was delete in the first line of initEnemyTurn is so does not run twice while the first tries to determine the player_turn.

    So it turns out that none of this had to do with the access to the function...

    Thanks for the help!

  • access a movieclip already on scene of a class of the document class?

    Hello!

    I have a new problem... I try to access MC which are already on the scene of a void class. I found an explanation here , but I do not understand how to continue.

    There are three options in this example, for example in the first option is the main class:

    public void Main()

    {

    If (internship) init()

    of another addEventListener (Event.ADDED_TO_STAGE, init);

    }

    public void init(e:Event_=_null):void

    {

    var foo:Foo = new Foo (internship);

    }

    and the Foo:

    public void Foo(stage:Stage)

    {

    If (internship) trace ("success"); output: success

    }//

    but where do I go from here?

    You are welcome.

    PS when you use the adobe forums, please check the useful/correct, if there is.

  • The extension of class + access to the children of the base class

    Hello.

    I am trying to create a kind of panels of information and tool for a project, similar to those on the Adobe Suite products. They will have a tab that you can double-click to open or close and title of the Panel will be on this tab.

    So I created a video called main and in it, I placed a textfield called txtTitle and a rectangular MovieClip called mTab. I duplicated the main twice on the stage, called PanelA and PanelB and add individual, but kept the txtTitle and mTab.  I edited the linking options of PanelA and PanelB to link to specific custom classes.

    First, I created a base for the main class.

    package com.panels {}

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    Import fl.text.TLFTextField;

    //

    SerializableAttribute public class MyPanel extends MovieClip {}

    //

    public void MyPanel (): void {}

    txtTitle.mouseEnabled = false;

    mTab.doubleClickEnabled = true;

    mTab.addEventListener (MouseEvent.DOUBLE_CLICK, clickedPanel);

    }

    }

    }

    And then the classes of Group A and B, which extend from the main.

    package com.panels {}

    import com.panels.MyPanel;

    //

    SerializableAttribute public class PanelA {MyPanel extends

    //

    public void PanelA (): void {}

    }

    }

    }

    When I test the movie, I get an error stating that 'Access of undefined property txtTitle' (and even to mTab). If I have just a PanelA link to the main class it all work - I got it to open, close, dragged with the mouse... I can access mTab, txtTitle and something else is already on the scene. But if I extend the class, I can't. Anyone know why this happens and how best to make it work? Thank you.

    use:

    SerializableAttribute public class MyPanel extends MovieClip {} Dynamics

    //

    public void MyPanel (): void {}

    this.txtTitle.mouseEnabled = false;

    this. mTab.doubleClickEnabled = true;

    ce. mTab.addEventListener (MouseEvent.DOUBLE_CLICK, clickedPanel);

    }

    }

    }

  • Access displays the objects within a class defined in a swc file?

    Is it possible to access display objects within a class defined in a swc file?

    To reproduce the problem:

    Step 1. I've set up a very simple FLA with an object defined in the library with the AssetView class:

    package

    {

    import flash.display.MovieClip;

    SerializableAttribute public class AssetView view extends

    {

    public var loader: MovieClip;

    public void AssetView()

    {

    Super();

    trace ("here it is:", charger);

    }

    }

    }

    In this object is a MovieClip with instance name loader. If the object is on the scene when the file is exported, you will see the trace:

    It's here: [object MovieClip]

    Step 2. I used Flash for publishing a swc, called "loader.swc".

    Step 3. I created a new actionscript project in Flash Builder and added "loader.swc" on the way to build ActionScript, the library, with the Type of link: merged into the code.

    Step 4. I instantiated "AssetView":

    var assetView:AssetView = new AssetView();

    I saw the trace:

    It's here: null

    --------

    I tried to delete the project actionscript AssetView class where it became priority during class with the CFC, but I still see no sign on the MovieClip.

    So, my question is, display objects are not accessible in the swc?

    + 1 for siniouse. The class definition does not contain the charger of the instance, but the symbol in the library only. If you need to

    var view: AssetView new MyLibrarySymbolLinkageName() as AssetView;

    What he says is quite likely to happen to you, but I thought I would add my 2 cents in the matter contributed to the clarification.

  • access the value in the document class

    Hello I am trying to access a value in the document class. but I can't make it work.

    what I have is:

    can someone tell me how to access the value of myArray?

    Bomberman.As:

    package {}

    import flash.display.MovieClip;

    public class bomberman extends MovieClip {}

    public var myArray:Array = []; trying to access this value

    public void bomberman() {}

    init();

    trace (document.docClass);

    }

    private void init() {}

    var square: Array = [];

    for (var i: Number = 0; i < 11; i ++) {}

    for (var j: Number = 0; j < 11; j ++) {}

    var temp: grassSquare;

    If (i == 0 |) I == 10) {}

    Temp = new grassSquare (i * 50, j * 40);

    addChild (temp);

    Square.push (temp);

    } Else if (i %2! = 0) {}

    If (j == 0 | j == 10) {}

    Temp = new grassSquare (i * 50, j * 40);

    addChild (temp);

    Square.push (temp);

    myArray.push (false);

    } else {}

    myArray.push (true);

    }

    } else {}

    If (j %2 == 0) {}

    Temp = new grassSquare (i * 50, j * 40);

    addChild (temp);

    Square.push (temp);

    myArray.push (false);

    } else {}

    myArray.push (true);

    }

    }

    }

    }

    }

    }

    }

    Bomberman.fla:

    import flash.events.KeyboardEvent

    var User1:Player1 = new Player1;

    stage.addEventListener (KeyboardEvent.KEY_DOWN, User1.fl_SetKeyPressed);

    User1.x = 75;

    User1.y = 60;

    addChild (User1);

    Player1.as:

    package {}

    import flash.display.MovieClip;

    import flash.events.Event;

    import flash.events.KeyboardEvent

    import flash.ui.Keyboard

    SerializableAttribute public class extends MovieClip {Player1

    private var upPressed:Boolean = false;

    private var downPressed:Boolean = false;

    private var leftPressed:Boolean = false;

    private var rightPressed:Boolean = false;

    private var currentSquare:uint = 12;

    public void Player1() {}

    this.addEventListener (Event.ENTER_FRAME, fl_MoveInDirectionOfKey);

    stage.addEventListener (KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);

    }

    public void fl_MoveInDirectionOfKey(event:Event)

    {

    If (upPressed & & this.y > = 100 /* & & document.myArray [currentSquare-1] * /)

    {

    This.y-= 40;

    upPressed = false;

    currentSquare-= 1;

    }

    If (downPressed & & this.y < = 340 / * & & this.myArray [currentSquare + 1] * /)

    {

    This.y = 40;

    downPressed = false;

    currentSquare += 1;

    }

    If (leftPressed & & this.x > = 125 / * & & /*this.myArray[currentSquare-11]*/)

    {

    This.x-= 50;

    leftPressed = false;

    currentSquare = 11;

    }

    If (rightPressed & & this.x < = 425 / * & & /*this.myArray[currentSquare+11]*/)

    {

    This.x += 50;

    rightPressed = false;

    currentSquare += 11;

    }

    trace (currentSquare);

    }

    public void fl_SetKeyPressed(event:KeyboardEvent):void

    {

    switch (event.keyCode)

    {

    case Keyboard.UP:

    {

    upPressed = true;

    break;

    }

    case Keyboard.DOWN:

    {

    downPressed = true;

    break;

    }

    case Keyboard.LEFT:

    {

    leftPressed = true;

    break;

    }

    case Keyboard.RIGHT:

    {

    rightPressed = true;

    break;

    }

    }

    }

    }

    }

    any class that is added to your list of display:

    MovieClip (root) .myArray

  • Instance of MovieClip Access on stage in the other classes

    Hello.

    I have the instance of movieclip on the stage.  Instance name qwe of the shiptype.

    I want to access it in other classes EnemyShip.as.

    I tried this.

    MovieClip (this.parent) .getChildByName ("qwe")

    but I got

    TypeError: Error #1034: Type coercion failed: cannot convert flash.display::Stage@26d03041 to flash.display.MovieClip.

    I don't have any class of document.

    Publish settings controlled on automatically declare stage instances.

    y at - it access qwe in EnemyShip.as anyway?

    And here is the link to my flash project:

    http://www.mediafire.com/?kf6uiunys20cyzz

    If the ship is created the instance of the enemy, you can pass the instance of the ship in the object of the enemy when you create it using something like...

    var enemyship: EnemyShip = new EnemyShip (this);

    and in your EnemyShip.as receive you and assign it to a variable, so that you can reference it beyond the EnemyShip function

    public var _qwe:MovieClip;

    public void EnemyShip(ship:MovieClip)

    {

    _qwe = ship;

  • To access the objects placed directly in the fla of the as3 class file?

    Hello

    I'm pretty new to flash and I do this game were traveling along a track and along this trail, there are a lot of boxes, I want my character to pick up.

    Now my question is, is it possible to use a symbol in the library and just place it on the track directly in the fla. folder and then power it hitTest with the character, I added in the as3 file?

    I hope I did, it's understandable.

    Thanks in advance!

    Sincerely of Smith

    Is your code in a separate class? If so, simply extend a display object (for example public class Foo extends Sprite). Then, you have access to the scene, as well as objects in the timeline panel.

    The code for hittest is quite simple. Continually check the hitTest, a test against an another movieclip movieclip method to see if it returns true. How do optimize you how many tests is performed are up to you. Management if the person is on the path you will help understand what are the objects to test against.

  • To access the upper class instance variables

    Hello

    See the code provided below. If home * variable 'i' is not set to 4, the output will be 3, if it is set, it will be 4.
    My question is... Well, I don't know exactly, there would be a lot. All this is strange to me.
    (For example, it seems that for the super class constructor runs when I access an instance of her variable).
    Could someone explain this topic or maybe help me to direct to an article?
    public class TryThis {
        
        public static void main (String args[]){
    
             Child c = new Child();
             c.seeSuper();   
        }
    }
    
    public class Parent {
    
         int i;
         
         Parent(){
              i = 3;
         }
    }
    
    public class Child extends Parent{
    
         Child(){
              //i = 4;  //***
         }
         
         public void seeSuper(){
              System.out.println(super.i);
         }
                        
    }
    Note: Parent could also simply look like this:
    public class Parent {
         int i = 3;
    }

    I see now that it is wrong to use the word 'object '.

    No, it isn't.

    they are there for the child to use, object

    That's where you're going wrong. Don't think about "the parent" and "child object. There is only one object, and it is mentioned by "this". You should think about members of the base or the classes and members of the (current) derived class. They are all members of the 'object', but the members of the base class can be hidden by the current members of class with the same name. That's all. Nothing too special about it.

    but they aren't the fields of it.

    Yes they are, but if they are hidden by local declarations that they are not visible to 'this', only to 'super '.

  • How to access the static class variable calendar / singleton?

    How can I access a timeline of a static class variable / singleton?

    You can pass any object to display list to your class when instantiating it.  all objects in the display list has a placement property that allows access to the stage and them you can use the correct path/name to your variable.

  • Access the ArrayCollection class MXML ActionScript collection?

    I have a MXML file that has a collection for my tree component arraycollection. I am overriding the updateDisplayList function to add lines to all of my nodes in the tree... However, I can't seem to understand how to access this ArrayCollection collection of inside the actionscript class?

    I tried the methods used to pass variables between two MXML files (like a popup window - which I've used in the past and it works very well).

    My actionscript class code is almost identical to this example here:

    http://www.iepl.NET/treeControlSample/treeControlSample.html

    In the example above, the data is static, but sometimes my data's going to change and I need to access the set dataProvider (collection ArrayCollection) in order to make the lines work well... This has been very frustrating for me! :)

    If someone knows a better way to reach gettign lines for brothers and sisters in a tree... Please let me know!

    Any help would be super duper awesome!

    I found the solution to this. My problem was similar to cheftimo was seen in this post:

    http://www.Adobe.com/cfusion/webforums/Forum/MessageView.cfm?forumid=60&CATID=585&ThreadId = 1367784 & enterthread = y

    The answer is to import the component you are trying to access the variable from and then call using mx.core.Application ' Application.application.'

    Thanks to Greg Lafrance!

  • urlLoader - replace it with the File class to access external resources

    Hello.

    Just read up on the File class more than anything because I want to develop on mobile devices. Can I replace all my classes urlLoader with the File class for my games on the web.

    var prefsFile:File = File.applicationDirectory;

    prefsFile = prefsFile.resolvePath ("preferences.xml");

    I feel that it is perhaps a silly question, but I have to ask.

    See you soon

    Yes, but you probably don't want to use applicationDirectory because of security concerns.

    and is there a reason you can't use your urlloaders?

  • How to access the inner class fields in refleciton?

    I have:
    class Outer {
        class Inner {
            int field;
        }
        Inner inner;
    }
    I use reflection to get the Outer.field field and recognize that it is a reference to the inner class. What should I do to get the inner.field (or something that looks remotely like this at Inner.field)?

    We would like to

    Well, precedent is too messy for me even follow my example. I've simplified it, and I think I found where my error was. I suspect that you were doing a similar error:

    package scratch;
    
    import java.lang.reflect.Field;
    
    public class Scratch {
    
      public static void main(String[] args) throws Exception {
        new Scratch().go();
      }
    
      void go() {
        Outer1 o1;
    
        Field[] fields = Outer1.class.getDeclaredFields ();
    
        for (Field field : fields) {
    
          final String fn = field.getName ();
          final Class ft = field.getType ();
          final Class fc = field.getClass ();
          final Class fdc = field.getDeclaringClass ();
    
          System.out.println ();
    
          System.out.println ("Outer1 field : " + fn);
    
          System.out.println ();
    
          System.out.println ("field's class (field.getType()) : " + ft.getName());
          System.out.println ("field.getType().isMemberClass() (" + ft.getName() +" isMemberClass()) : " + ft.isMemberClass ());
          System.out.println ("field.getType(). getDeclaringClass() (" + ft.getName() + "'s declaring class) : " + fdc);
    
          System.out.println ();
    
          System.out.println ("field.getClass()) : " + fc.getName());
          System.out.println ("field.getClass().isMemberClass() (" + fc.getName() +" isMemberClass()) : " + fc.isMemberClass ());
          System.out.println ("field.getClass().getDeclaringClass() (" + fc.getName() + "'s declaring class) : " + fc.getDeclaringClass ());
    
          System.out.println ();
    
          System.out.println ("Note the difference between Field.getClass() (" + field.getClass () + ") and Field.getType() (" + field.getType() + ")");
    
          System.out.println ();
        }
      }
    }
    
    class Outer1 {
      class Inner1 {
      }
    
      Inner1 i1;
    }
    
    Outer1 field : i1
    
    field's class (field.getType()) : scratch.Outer1$Inner1
    field.getType().isMemberClass() (scratch.Outer1$Inner1 isMemberClass()) : true
    field.getType(). getDeclaringClass() (scratch.Outer1$Inner1's declaring class) : class scratch.Outer1
    
    field.getClass()) : java.lang.reflect.Field
    field.getClass().isMemberClass() (java.lang.reflect.Field isMemberClass()) : false
    field.getClass().getDeclaringClass() (java.lang.reflect.Field's declaring class) : null
    
    Note the difference between Field.getClass() (class java.lang.reflect.Field) and Field.getType() (class scratch.Outer1$Inner1)
    

    field.getClass () does NOT get the class of the field. It get the class of the field object that points to the field reference variable, which is always java.lang.reflect.Field. To get the class of the field, use field.getType ().

    Do you see the difference?

    Edited by: jverd February 5, 2011 17:18

Maybe you are looking for