Notify qml another class

My brain is a little drained and I can't seem to connect the signals correctly.

I have a class of the main application.

In the present, I create main.qml and use setContextProperty post a pointer to class B.

I'm starting a process b by calling B.start () in qml.

When B is finished it beeps Rollback()

How to receive this signal in qml?

Do I have to use connections?

Actually and surprisingly to me, we can "import QtQuick 1.0" for some positions (those non-Visual, I guess), including the connections. Paste them into an attachedObjects: list [] and you should be good.  For example:

import QtQuick 1.0
...
SomeControl {
    ...
    attachedObjects: [
        Connections {
            target: Application
            onThumbnail: console.log("** thumbnailed!")
        }
    ]
}

On the other hand, you don't have to use it, since you can simply connect programmatically:

import bb.cascades 1.0

SomeControl {
    ...
    function thumbnailed() {
        console.log("** thumbnailed!");
    }

    onCreationCompleted: {
        Application.thumbnail.connect(thumbnailed);
    }
}

I expect one or the other to work for your case.

Tags: BlackBerry Developers

Similar Questions

  • Refresh JComboBox in one class when a changes JList in another class?

    Hello
    I have a small program where I am trying to update a JComboxBox in my class Main.java (a JFrame) when the contents of a JList change in another class JFrame, ProjectManager.java

    I have three classes involved in the present.

    Main
    Poster of the JComboBox

    ProjectManager
    Displays the JList and here you can add/remove items in the JList
    When this happens I want changes to be reflected in the main class

    ProfileManager
    The above two classes get their datamodel of this class by calling the static methods:
    public static ListModel getProfileListModel()
    and
    public static ComboBoxModel getProfileComboboxModel()
    I'm new to Java/Swing and I guess I'm must write a ListDataListener who warns 'Hand' that JList has changed.
    Who update the JComboBox.

    The problem is how to do that when I have three classes involved?

    I tried to create this listener in the main class:
     class ProfileListDataListener implements ListDataListener {
    
            public void contentsChanged(ListDataEvent e) {
                getProfiles();
            }
    
            public void intervalAdded(ListDataEvent e) {
                getProfiles();
            }
    
            public void intervalRemoved(ListDataEvent e) {
                getProfiles();
            }
            
        }
    getProfiles() looks like this:
    private void getProfiles() {
    cmbProfiles.setModel(profileManager.getProfileComboboxModel());
    }
    I can't add this listener to the ListDataModel since my class of earphone is not static, and if I do static, I can't call the method not static getProfiles().

    Anyway, my question is, what is the right way to do it when I want to notify a listener in the main class of class ProjectManager?

    Thank you.

    There are several ways (and I hope at least one is correct)
    You tell us how you want to update the drop-down list.
    I guess it must reflect the content of the JList. Yet,.
    I will describe the General.

    1)
    -you create hand declaring the combo as a global variable
    -you create ProjectManager by passing a reference to hand
    -join a listener JList of ProjectManager
    When the listener fires, you have access to the drop-down list via the reference of hand and the update.

    1A)
    Rather than attach the listener to the JList, you can attach it to its model,
    that might be in ProfileManager. In this case ProfileManager should have the
    the reference to hand. -By the way: you have several instances of hand or ProjectManager?
    I do not see the need for static methods in ProfileManager yet.

    2)
    -you create hand
    -you create an instance of the ProjectManager and ProjectManager must declare his
    JList as a global variable
    -You can access this list via the instance of ProjectManager
    -join a listener this list in hand and update the drop when the
    lights of the listener.

    2A)
    Rather than attach the listener to the JList, you can attach it to its model,
    that might be in ProfileManager. In the main case must have a reference to
    ProfileManager.

    I personally prefer to have the Jlist and its auditor in the same class.
    And if my assumption is right that the combo should reflect the content of the JList,
    There is no need of the ProfileManager class if his job is only to define models of
    the JList and the JCombobox.

  • (Question LVOOP) How one access the data of another class in another class?

    Hello-

    Ass title suggests, how do I access another class (or is it class?) data from another (different) class?  I will attach a picture showing where my problem is...

    I was told this:

    http://zone.NI.com/reference/en-XX/help/371361H-01/lvhowto/setting_scope_classes/

    May contain some helful info, but I can still understand how to unbundle Renault of classes inside the component class data (as seen in the attached photo).

    I think there could be something simple I'm missing here when it comes LVOOP or OBJECT-oriented programming in general... If any of you are willing to help me, it would be much appreciated!

    Thank you!

    -pat

    Personal data are always private, you can never set public. Unbundle cluster function can be used only on the thread of class when he is in the class. If you need to access private data, you must create accessors.

    It of simple, just the class right click and select new, VI for access data members. He invites you to a dialog box to fill you with what you want to create, elements of data and if you want them available through property nodes (recommended). Once completed, this will generate the Afterward screw., you can use in any other VI. The nice thing about making them nodes of property is that you can plop down a property node and it thread class, and all the created accessor functions will appear in the list.

  • How do I know if a class LV object has a relationship of 'is - a' with another class?

    Hi all

    I have a question LVOOP.

    Let's say I have a class object. The class of the object, it's that I have developed. Now, I would like to know if the object has a relationship of 'is - a' with another class.

    How can I do?

    One solution I have is to use "more specific class ' and check the status of the error. But I thought that there is a better way that I don't know.

    Thank you

    TailOfGon wrote:

    One solution I have is to use "more specific class ' and check the status of the error. But I thought that there is a better way that I don't know.

    It is the right solution. What dislikes on this subject?

  • Back in another class vector

    I am trying to create a vector in my class of network. I want to fill my popup screen with the same vector. Can someone tell me how I would return the vector in another class where my popup is called from.

     final class NetworkGetConnectionClassGeoCode 
    
    System.out.println(address);
    _datageocode.addElement(new DataGeoCode(address)); 
    
    class DetailScreen extends FullScreen 
    
    public void showDialog() { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { CustomPopup screen = new CustomPopup(NetworkGetConnectionClassGeoCode.,_data.getAddress()); _controller.getUiApplication().pushModalScreen(screen); String newEndPoint = screen.getEndPoint(); String newStartingPoint = screen.getStartingPoint(); } }); }
    

    Hi onelson06,

    You can create a static vector in your invocation class. so if you have a static vector in DetailScreen, just fill in your popup via DetailScreen.yourstaticvector.addElement ().

    or you can create a static method in your class that is invoking as setVectorData(Vector v) and invoke this in your pop-up screen to move to the previous screen.

    I hope this helps.

    Cheers!

  • Using a function from another class

    Information: Blackberry JDE 7.1.0

    BlackBerry 9930 Simulator - V 4.0.0.141

    The title of the topic seems simple, but I'm actually trying to use a X of class A function inside a function Y of class B and the GET, the value returned by X to a variable in B.

    Let me start by explaining what I currently have and then go on what I'm doing.

    I am using this class, the code for which I found online, to create a scrollable multi-line textbox.

    public class TextBoxField extends VerticalFieldManager {
    
          //define some variables to be used
          //in the class
          private int managerWidth;
          private int managerHeight;
          private EditField editField;
    
          public TextBoxField(int width, int height) {
                super(Manager.NO_VERTICAL_SCROLL);
                managerWidth = width;
                managerHeight = height;
    
                VerticalFieldManager vfm =
                    new VerticalFieldManager
                      (Manager.VERTICAL_SCROLL);
    
                  editField = new EditField(){
                    public void paint(Graphics g) {
                    getManager().invalidate();
                    super.paint(g);
                  }
                };
    
                vfm.add(editField);
                add(vfm);
              }
    
          public void paint(Graphics g) {
              super.paint(g);
              g.drawRect(0, 0, getWidth(), getHeight());
            }
    
          public void sublayout(int width, int height) {
              if (managerWidth == 0) {
                managerWidth = width;
              }
              if (managerHeight == 0) {
                managerHeight = height;
              }
              super.sublayout(managerWidth, managerHeight);
              setExtent(managerWidth,managerHeight);
            }
    
          public String getText() {
                return editField.getText();
              }
              public void setText(String text) {
                editField.setText(text);
              }
            }
    

    Then in another class that I created a "Set" function that instantiates the class textbox, to create two text boxes and a richfieldtext, add them to a HorizontalFieldManager and return the HorizontalFieldManager.

     HorizontalFieldManager Set(int set){
            HorizontalFieldManager hr1=new HorizontalFieldManager(FIELD_HCENTER);
    
            RichTextField set1 = new RichTextField("SET " + set + ":"){
                protected void layout(int width, int height)
                {
                    super.layout(75,30);//Width and height according to the button name;
                    setExtent(75,30);//width and height according to the button name;
                }
            };
            set1.setPadding(10, 5, 10, 10);
            TextBoxField set1W = new TextBoxField(40,25);
            set1W.setPadding(10, 5, 10, 0);
            TextBoxField set1R = new TextBoxField(40,25);
            set1R.setPadding(10, 5, 10, 0);
    
            hr1.add(set1);
            hr1.add(set1W);
            hr1.add(set1R);
    
            return hr1;
        }
    

    Now in my main class I call this function to add a 'Set' on the screen using:

    add(Set(1));
    

    For the creation of the 'Set' function instead of using the instance of the textbox class in the main class itself, it is because I will create several 'sets '.

    Now, as you can see, there is a public String getText() function in the TextBoxField() that returns the value of the editField. What I need to do, is to get the value in this field, once you press a button.

    I have the code for the function button, so this isn't a matter of concern. However I do not know how to retrieve the editField value when the button is pressed. I can get the value inside the Set()function, using the:

    String getval = set1W.getText();
    

    but can't reach it from the outside. I don't even know if it's possible in the first. If it is not could someone suggest a way where I could retrieve these values.

    Any help is appreciated.

    Thank you.

    Thanks for the suggestion. I found another workaround solution. Essentially implementation of an array of TextBoxFields and then pass them one by one the "Set()" method

    I tried this at the start before posting here, but due to a careless mistake when you declare the array of TextBoxFields, I couldn't make it work.

    In any case, the topic can be closed now, because the problem has been resolved. Thank you.

  • pushScreen does not not when calling another method of another class

    Hi all

    Earlier today, I was able to get a program that is running and I was actually pretty happy with it despite the fact that he has a lot of bugs.  However, in attempting to remove bugs and me being stupid and forget to backup my previous code that it no longer works. In any case the line of code that I used was

    UiApplication.getUiApplication () .pushScreen (ScanScreen ());

    ScanScreen is a method that I created in another class.

    Any help is greatly appreciated thanks!

    Thanks for all the help!  I just made a new button and pushed the event from there.  He works for now so thank you again for all the help everyone!

  • How to get the menuitem created in another class

    Hello

    I created a class. on the inside I added a few menus using addMenuItem (Map);

    final class UserInterfaceTouch extends MainScreen
    {
    
     UserInterfaceTouch() {
            super();
    
            LabelField title = new LabelField("Nutiteq SDK Map Sample",
                    LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
    
            setTitle(title);
            addMenuItem(_test);
    
        }
    MenuItem _otest = new MenuItem("Testing, 10, 10) {
            public void run() {
                --- code for doing some thing
            }
        };
    }
    

    How do I acess the menu in the class thus form another class, is it possible to do so.

    Thank you

    SujithRavindran

    Sorry for posting this.

    I got the answer.

  • instantiate a class via an argument to constructor of another class.

    public void LevelManager (owner: Home)

    {

    _owner = owner;

    }

    In my LevelManager class, I have the code above in the constructor. The House is another class that is not instantiated anywhere with the new keyword. It is simply a parameter in the constructor and then past in the body and assigned to a local variable. I didn't know that you could instantiate a class through a function parameter. Is this true?

    Congratulations in advance.

    This code is not instantiate the reception class. This code assumes that when you instantiate LevelManager, you pass an instance of the House.

    This class does not create an instance but store the reference to an instance created elsewhere except in cases when the null value is passed.

  • Calling functions from another class

    How one accesses a function from another class?

    Let's say I have a file called .as hand. My flash file uses this as this is the main class to make it work when you test the program. Let's say I have another class named Test that looks like this:

    package

    {

    public class Test

    {

    public void Test()

    {

    trace ("why don't you work?');

    }

    }

    }

    I want call the Test function when the game takes place (in the appellant to hand), how would he enter the main run file? I imported to it, made sure that the functions were public/static, created as a variable and it still doesn't work.

    Any help would be good

    the constructor for a class is different from a 'normal' function

    If you can't do something like

    meow: Test of var = new Meow();

    To call it thus:

    test: Test of var = new Test();

    test. Meow();

  • methods of class in another class

    Hello

    I would like to know is there is another way than I do with the embeded classes in another:

    ex I have a device class that hosts a class Com (RS - 232...)

    what I do I want to setup a com of a device is get com device object then appliing change the COM with com whan methods

    is there a way to apply the com method directly to the device?  I thought to get instr, method in the Com class so unbundle is directly

    but I don't think it's a good thing...

    Is there something to do with the class friend or community?

    See the attached .jpg

    Concerning

    Tinnitus

    In the photo, I assume you mean associations and design of composition model.

    You can simply implement accessor screws in the Instr.class to get/set the Com.class. Using a design of val, you would call get the Com.class, regardless of the methods on the Com.class and then put it back in the Set accessor: Inst.class.SetCom (Com).

    Using a design by reference, you don't need the Setter and can set the ReadOnly property of Com of Instr.class. But then you do the sequencing (program flow) by the single thread of error.

    Felix

  • QMetaObject::invokeMethod call of another class, CRASH

    OK, I have 3 classes: applicationui, fireball AND hilotimer.

    So far, use only 2 classes (applicationui AND fireball), had no problem when you use QMetaObject: InvokeMethod. This method, I have in a SLOT that runs whenever a web request is made correctly and from there I have to call a function in main.qml that is responsible for the analysis of the response in JSON format.

    Well, it's time to add a new class to my project (hilotimer), it is a thread that runs a timer that periodically calls a function belonging to the ball of fire class and finally the LOCATION mentioned above, but when the calls run QMetaObject: InvokeMethod, the application breaks.

    The structure goes like this:

    hilotimer.cpp

    #include "hilotimer.hpp".
    #include "fireball.hpp".

    {hilotimer::hilotimer()}
    Timer = new QTimer (this);
    QObject::connect (timer, SIGNAL (timeout ()), this, SLOT (sessionTokenVencido ()));
    }

    {hilotimer::~hilotimer()}

    }

    void hilotimer::run() {}
    Timer-> start (20000);
    }

    void hilotimer::detenerTimer() {}
    Timer-> stop();
    }

    void hilotimer::sessionTokenVencido() {}
    Fireball * fball = new fireball();
    Fball-> renovarSesion();
    }

    Fireball.cpp (only the methods in conflict)

    ball of fire: renovarSesion() Sub {}
    (global var) tipoPeticion = "facilitate";
    QSettings config ("Poncho Labs", "Fireball");
    configuracion.beginGroup ("session");
    (global var) sessionToken = configuracion.value("session_token").toString ();
    configuracion.endGroup ();
    QNetworkAccessManager * accessMgr = new QNetworkAccessManager (this);
    Connect (accessMgr, SIGNAL (finished(QNetworkReply*)), this, SLOT (finPeticion(QNetworkReply*)));
    Petición QNetworkRequest = QNetworkRequest();
    QSslConfiguration sslConfig;
    sslConfig.setProtocol (QSsl::TlsV1);
    peticion.setSslConfiguration (sslConfig);
    peticion.setUrl (QUrl ("INTERESTING URL");
    accessMgr-> get (request);
    }

    void fireball::finPeticion (QNetworkReply * response) {}
    QString strRespuesta;
    if(respuesta->Error() == QNetworkReply::NoError) {}
    strRespuesta = QString (response-> readAll());
    qDebug()<>
    QMetaObject::invokeMethod (master, "jsonDecoder", Q_ARG (QVariant, strRespuesta), Q_ARG (QVariant, tipoPeticion)); CRASH
    }
    else {}
    QMetaObject::invokeMethod (master, "llamarDialogo", Q_ARG (QVariant, tipoPeticion)); CRASH
    }
    respuesta-> deleteLater();
    }

    jsonDecoder is a js function in main.qml

    The crash error is: 33161460 (FireBall) process terminated code SIGSEGV = 1 fltno = 11 ip=79689ce6(/base/usr/lib/qt4/lib/libQtCore.so.4.8.5@_ZNK11QMetaObject13indexOfMethodEPKc+0x25) mapaddr = 0012dce6 ref = 00000012 bdslot = 1

     


    I have no idea about that, can u help me? SORRY FOR THE BAD ENGLISH

    In the end, I had to rebuild the function fireball: renovarSesion() and remove all .js functions called in the qml file. Thx for you answer.

  • How to change a tab active tabbedpane qml another?

    Hello

    Let's say I have a sheet with a few buttons in the menu. I have three buttons called menu 1, menu 2 and 3. Then I have another file qml tabbedpane with three tabs... I am able to show the tabbedpane when I click on the buttons, but how can I change the active of the tabbedpane tab when the user clicks on the menu 2 and the active tab change 2 tab? How can I achieve this?

    Thank you.

    Hi, from your description, you must assign an id to each tab and tabbedpane. Then in the onClicked button slot you write like this

    onClicked: {
          tabbedpane.activeTab = tab2;
    }
    
  • integer to another class problem, please help :D

    I tried a day now to solve this problem and I'm stumped. Could someone please point out what's wrong with the following code? I'm moving an integer of a class to another.

    ButtonField nextBut = new ButtonField ("Next", Field.FIELD_HCENTER) {}
    protected boolean trackwheelClick (int status, int time) {}
    If (firstChoice == 0) {}
    Dialog.Alert ("you must choose!");
    }
    else {}
    int firstChoices = firstChoice;
    UiApplication.getUiApplication () .popScreen (Ui.getUiEngine () .getActiveScreen ());
    UiApplication.getUiApplication () .pushScreen (new newGame3 (firstChoices));
                       
    }
    Returns true;        }
    public int getPreferredWidth() {}
    Return Display.getWidth ();
    }
    Protected Sub paint (Graphics Graphics) {}
    graph.setBackgroundColor (Color.BLUE);
    graph.fillRect (0, 0, getWidth(), getHeight());
    graph.setColor (Color.RED);
    Graph.Clear ();
    Super.Paint (Graph);
    }
    };
           
    nextBut.setFont (Font.getDefault () .derive (Font.BOLD));
           
    FieldChangeListener lnextBut = new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}
    }
    }
    ;
    nextBut.setChangeListener (lnextBut);
    VMAN. Add (nextBut);

    the other class

    public class newGame3 extends form {}
       
    public newGame3 (int firstChoices) {}
    LabelField t1 = new LabelField ("new game 3" + firstChoices);
    Add (T1);
    }
    }

    I think Rexdoug meant firstChoice.

    Give a look at this example. You should get whats wrong on your code.

    public class TestScreen extends MainScreen
    {
        int firstChoice = 5;
        public TestScreen()
        {
            ButtonField nextBut = new ButtonField(" Next ", Field.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
            FieldChangeListener lnextBut = new FieldChangeListener()
            {
                public void fieldChanged(Field field, int context)
                {
                    UiApplication.getUiApplication().popScreen(Ui.getUiEngine().getActiveScreen());
                    UiApplication.getUiApplication().pushScreen(new NewGame3(firstChoice));
                }
            };
            nextBut.setChangeListener(lnextBut);
            this.add(nextBut);
        }
    } 
    
    class NewGame3 extends MainScreen
        {
            public NewGame3(int firstChoice)
            {
                LabelField t1 = new LabelField(" New Game 3 "+ firstChoice);
                this.add(t1);
            }
        }
    

    Concerning

    Bika

  • How to access a movieclip on the class of document of another class?

    Hello!

    Go further on my application, I felt in another problem. Although they have a lot of messages on the web in this respect, none of the solutions worked for me

    In my document class two containers (Main.as) I ve. A void and another with a star that is imported to the library. Here´s the main class:

    package 
    {
         import flash.display.*;
         public class Main extends MovieClip
         {
              public var container1:Sprite;
                    public var container2:Sprite;
              var _star:star;
              public function Main()
              {
                   // First container
                   container1=new Sprite();
                   container1.x = 50;
                   container1.y = 200;
                   stage.addChild(container1);
                      _star=new star();
                   container1.addChild(_star);
    
                            //Second container
                            container2=new Sprite();
                            stage.addChild(container2);
                   
              }
         }
    
    }
    

    Right now I ve a star placed inside a container and the container is placed on the stage. I also created an additional container named container2.

    Now, I want to define a base class for the star. I named it as experience. Here it is:

    package 
    {
         import flash.display.*;
         import flash.events.*;
         public class Experience extends MovieClip
         {
              public function Experience()
              {
                   // constructor code
                   this.addEventListener(MouseEvent.MOUSE_CLICK,Clicked);
              }
                   public function Clicked(evt:MouseEvent):void
                    {
                          trace("Star was clicked");
                          this.parent.alpha=0; //travels back to container1 and sets alpha to zero.
                          //how can I access container2? this.parent.parent.container2 doens´t work!
                    }
    
    
            }
    }
    

    Inside of the "Clicked" function I want to access the container2 placed on the stage.

    I tried:

    this.parent.parent.container2.x=0;
    

    which gives me the error:

    1119: access of container2 property possibly not defined through a reference with static type flash.display:DisplayObjectContainer.

    I ve set the two containers as public. In this way the two is accessible off hand.

    In the meantime, I also tried to step to the constructor of the base class.

    The idea is to have the scene on the base class and so call containers directly from the stage.

    In the constructor of the main class, I add:

    home= this.stage;
    var pencil:Experience = new Experience(home);
    

    Then, in the base class I change the constructor and added something:

                                  .
                                  .
                                  .               
    private var _stage:Stage;
    
              public function Experience(home:Stage)
              {
                   _stage = home;
                                  .
                                  .
                                  .
    

    However, when I put as the class basis of the star movieclip class I get an error. If it works, but I want to put the class as a base class for this doesn´t approach meets my needs

    How can I do this?

    I hope you can help me! I want to use the classes but very delicate they´re!

    Thanks in advance for all,

    Best rgds

    You can use an event listener and the event dispatcher to listen to events to happen, something like this:

    star.addEventListener(MouseEvent.MOUSE_DOWN, callContainer2Function);
    
    function callContainer2Function(event:Event):void{
         trace("calling container2");
         //dispatch string event
         dispatchEvent(new Event("Calling container 2"));
    }
    
    container2.addEventListener("Calling container 2", container2Response, true);
    
    //When the container2 hears the string you dispatched, it will fire this function
    function container2Response(e:Event):void {
         trace("Container2 responding")
         //do your code
    }
    

    Hope that helps,

    ~ chipleh

Maybe you are looking for