How the components in C++ QML?

Hello

I have the below QML and C++ code and I want to emphasize the element of container QML in C++,

but I write code C++ does not work for the component container with id = container. Please suggest what the problem?

Page

{
Container
{
ID: container
layout: StackLayout
{
direction: LayoutOrientation.TopToBottom
}
Button
{
ID: submit
text: 'submit '.
}
}
}

C++ code

QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);

Create the root for the UI object
Page * root = qml->() createRootObject;
QObject * container = root->findChild ('container');

The ID is how you refer to it in QML. objectName is the property you need to refer to it in C++.

See https://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/

Tags: BlackBerry Developers

Similar Questions

  • 15 - n205nr: HOW can I GET a BUILD LIST all THE COMPONENTS OF MY LAPTOP HP 15-n205nr?

    HOW can I GET A BUILD LIST SHOWING all THE COMPONENTS OF MY LAPTOP HP 15-n205nr?

    Hello

    His record:

    http://support.HP.com/us-en/document/c04026602

    and hardware information:

    http://PartSurfer.HP.com/search.aspx?SearchText=F5Y79UA

    Kind regards.

  • How to set the Volume on the media player in QML

    Hello

    I would like to adjust the volume of my QML Media Player object. According to the documentation:

    http://developer.BlackBerry.com/native/reference/Cascades/bb__multimedia__mediaplayer.html

    MediaPlayer class has a setVolume method, but I get:

    TypeError: Result of expression 'myPlayer.setVolume' [undefined] is not a function.

    How can I adjust the volume in QML?

    Hi burakk,

    Here are the steps that you must follow to adjust the volume by QML programming:

    (1) define a signal myVolumeChanged to the main control QML

    (2) define a slot that handles the signal preceding once it is triggered by the volume control of the MediaPlayer with the new volume

    (3) fire this signal into the slots of the buttons onClicked two volume

    I tried the above using the nowplaying waterfalls sample app and were able to achieve what you're trying to do, which is affecting the volume of the MediaPlayer using two buttons volume QML. Here's the code I added in the file main.qml from the sample application for your reference:

    import bb.cascades 1.2
    import bb.multimedia 1.0
    
    Page {
        property double newVolume: 4
        signal myVolumeChanged()
    
        onMyVolumeChanged: {
            player.setVolume(newVolume);
        }
    
        Container {
            layout: DockLayout {}
    
            ImageView {
                ...
            }
    
            Label {
                ...
            }
    
            //! [1]
            ProgressBar {
                   ....
            }
            //! [1]
    
            Container {
                layout: StackLayout {
                    orientation: LayoutOrientation.LeftToRight
                }
    
                Button {
                    text: "Increase Volume"
                    onClicked: {
                        newVolume = newVolume + 1
                        myVolumeChanged();
                    }
                }
                Button {
                    text: "Decrease Volume"
                    onClicked: {
                        newVolume = newVolume - 1
                        myVolumeChanged();
                    }
                }
            }
        }
    
        attachedObjects: [
            //! [2]
            MediaPlayer {
                id: player
    
                sourceUrl: "music/song.mp3"
            },
            //! [2]
    
            //! [3]
            NowPlayingConnection {
                id: nowPlaying
                ...
    
            }
            //! [3]
        ]
    }
    
  • How to move the components to display comments on the left of the screen instead of the right? Thank you, Jemma

    Hi, I would like to change the components to display comments on the left side of the screen rather than the default. How do I do this in Adobe Reader? Thank you, Jemma

    Hey jemmah62214493,

    I'm sorry this is not possible. However you can still fill out a feature request for this feature request/Bug Report Form for this.

    Kind regards

    Nicos

  • How to drag and drop nodes to tab between the components of the tab

    I'm working on this tutorial example ( feature drag - move in the JavaFX Applications |) JavaFX tutorials and Documentation 2 ). Based on the tutorial I want to drag tabs between two tabs. So far, I have managed to create this code, but I need help to complete the code.

    Source

    tabPane = new TabPane();
    Tab tabA = new Tab();
       Label tabALabel = new Label("Main Component");
    
    
    tabPane.setOnDragDetected(new EventHandler<MouseEvent>()
            {
                @Override
                public void handle(MouseEvent event)
                {
                    /* drag was detected, start drag-and-drop gesture*/
                    System.out.println("onDragDetected");
    
                    /* allow any transfer mode */
                    Dragboard db = tabPane.startDragAndDrop(TransferMode.ANY);
    
                    /* put a string on dragboard */
                    ClipboardContent content = new ClipboardContent();
                    content.put(DataFormat.PLAIN_TEXT, tabPane);
                    db.setContent(content);
    
                    event.consume();
                }
            });
    

    What is the correct way to insert the contents of the tab as an object? In the tutorial simple text is transferred. How do I change this line content.put(DataFormat.PLAIN_TEXT, tabPane); ?

    And what is the right way to insert the tab after that I drag the tab:

    Destination


    tabPane.setOnDragDropped(new EventHandler<DragEvent>()
            {
                @Override
                public void handle(DragEvent event)
                {
                    /* data dropped */
                    /* if there is a string data on dragboard, read it and use it */
                    Dragboard db = event.getDragboard();
                    boolean success = false;
                    if (db.hasString())
                    {
                        //tabPane.setText(db.getString());
                        Tab tabC = new Tab();
                        tabPane.getTabs().add(tabC);
                        success = true;
                    }
                    /* let the source know whether the string was successfully
                     * transferred and used */
                    event.setDropCompleted(success);
    
                    event.consume();
                }
            });
    



    I guess that this transfer is possible?

    REF javafx 2 - How to drag and drop nodes between the components of the tab - stack overflow tab

    I use a graphic (instead of text) for tabs and call setOnDragDetected on this chart. That way you know which tab is moved. There is no nice way to put the tab itself in the dragboard because it is not serializable (see https://javafx-jira.kenai.com/browse/RT-29082), so you'll want to probably just store currently slipped into a property tab.

    Here's a quick example; It only add the tab at the end of the existing tabs in the pane has fallen. If you want to insert it in the location that is closest to the actual drop you probably browse the tabs and find details of chart of each tab, or something.

    import java.util.Random;
    
    import javafx.application.Application;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.control.Tab;
    import javafx.scene.control.TabPane;
    import javafx.scene.input.ClipboardContent;
    import javafx.scene.input.DragEvent;
    import javafx.scene.input.Dragboard;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.input.TransferMode;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    
    public class DraggingTabPane extends Application {
    
      private static final String TAB_DRAG_KEY = "tab" ;
      private ObjectProperty draggingTab ;
    
    @Override
      public void start(Stage primaryStage) {
      draggingTab = new SimpleObjectProperty<>();
      TabPane tabPane1 = createTabPane();
      TabPane tabPane2 = createTabPane();
      VBox root = new VBox(10);
      root.getChildren().addAll(tabPane1, tabPane2);
    
      final Random rng = new Random();
      for (int i=1; i<=8; i++) {
        final Tab tab = createTab("Tab "+i);
        final StackPane pane = new StackPane();
          int red = rng.nextInt(256);
          int green = rng.nextInt(256);
          int blue = rng.nextInt(256);
        String style = String.format("-fx-background-color: rgb(%d, %d, %d);", red, green, blue);
        pane.setStyle(style);
        final Label label = new Label("This is tab "+i);
        label.setStyle(String.format("-fx-text-fill: rgb(%d, %d, %d);", 256-red, 256-green, 256-blue));
        pane.getChildren().add(label);
        pane.setMinWidth(600);
        pane.setMinHeight(250);
        tab.setContent(pane);
        if (i<=4) {
          tabPane1.getTabs().add(tab);
        } else {
          tabPane2.getTabs().add(tab);
        }
      }
    
      primaryStage.setScene(new Scene(root, 600, 600));
      primaryStage.show();
      }
    
      public static void main(String[] args) {
      launch(args);
      }
    
      private TabPane createTabPane() {
        final TabPane tabPane = new TabPane();
        tabPane.setOnDragOver(new EventHandler() {
          @Override
          public void handle(DragEvent event) {
            final Dragboard dragboard = event.getDragboard();
            if (dragboard.hasString()
                && TAB_DRAG_KEY.equals(dragboard.getString())
                && draggingTab.get() != null
                && draggingTab.get().getTabPane() != tabPane) {
              event.acceptTransferModes(TransferMode.MOVE);
              event.consume();
            }
          }
        });
        tabPane.setOnDragDropped(new EventHandler() {
          @Override
          public void handle(DragEvent event) {
            final Dragboard dragboard = event.getDragboard();
            if (dragboard.hasString()
                && TAB_DRAG_KEY.equals(dragboard.getString())
                && draggingTab.get() != null
                && draggingTab.get().getTabPane() != tabPane) {
              final Tab tab = draggingTab.get();
              tab.getTabPane().getTabs().remove(tab);
              tabPane.getTabs().add(tab);
              event.setDropCompleted(true);
              draggingTab.set(null);
              event.consume();
            }
          }
        });
        return tabPane ;
      }
    
      private Tab createTab(String text) {
        final Tab tab = new Tab();
        final Label label = new Label(text);
        tab.setGraphic(label);
        label.setOnDragDetected(new EventHandler() {
          @Override
          public void handle(MouseEvent event) {
            Dragboard dragboard = label.startDragAndDrop(TransferMode.MOVE);
            ClipboardContent clipboardContent = new ClipboardContent();
            clipboardContent.putString(TAB_DRAG_KEY);
            dragboard.setContent(clipboardContent);
            draggingTab.set(tab);
            event.consume();
          }
        });
        return tab ;
      }
    }
    
  • How do you know if (a) or the components are disabled

    Hello

    I am writing a custom test agent. If a modal dialog box appears (as a warning), and then the main SWF file is disabled.

    I want to programmatically make up for it.

    Right now, my agent is running on the components test steps even if they are disabled (due to modal alert pop up).

    Can someone tell me how?

    Thank you

    Pradeep.

    Hi PgPradeep,

    You can programmatically capture this by using the systemManager class...

    So if you open pop-up windows or a systemManager alert window will track the number of modal windows...

    If (SystemManager.numModalWindows > 0)
    {

    //
    }

    If this post answers your question or assistance, please mark it as such.

    Thank you

    Jean Claude Chari

  • How to remove the components?

    For some reason I can't do throw DBCA, also during the installation I couldn't uncheck the...

    Untitled1.jpg

    Hello

    It's normal. You can not remove the components if you install a database of the container of 12 c (A.K.A Multitenant).

    I have raised an idea to allow. See: Allow, deselect the options to database during the installation of Oracle shared 12 c

  • [ADF, JDev12.1.3] How to change the font size for all of the components of output within an af:panelBox?

    Hallo,

    I need to change the font size for all the inputTexts, LOVs of outputText, labels, etc. which are in different panelFormLayouts inside a panelBox.

    I tried to define a CSS class and to assign to the panelBox but it has not worked.

    You kindly suggest me an easy way to do this?

    Thank you

    Federico

    Hello

    You can try something like this:

    AF | panelBox::content label, af | panelBox::content, af | panelBox::content entry, af | panelBox::content select {}

    your style

    }

    At least the style of the components you named should be changed. If you need more you can add others.

    Kind regards

    Ruben.

  • Save all the components of database

    I'm working on a Board that was created some time in Multisim/Ultiboard V8 by someone else. Unfortunately, he did not leave with the client libraries, and almost all parts are its custom parts. In other words, they are not in one of the libraries that I have.

    How can I save all the components in the design, in the library 'corporate '?

    I know that I can make them one at a time, but then he y seven leaves and dozens of components. Is there a way to save everything in the library all at once?

    Phil

    Hi Phil,

    There is unfortunately no way to record all the components at the same time. You must right click on each component and select Save to DB component, then select your database.

    Kind regards

  • How to pass a QString QML to C++

    Hello

    How can I pass a QString QML to C++ and add it to a list view. Here's the code that describes my problem.

    I have a mainpage that contains a list view:

    // applicationui.cpp[...]void ApplicationUI::initFullUI() {
    
        QmlDocument *qml = QmlDocument::create("asset:///Main.qml").parent(this);
        qml->setContextProperty("app", this);
    
        // Create root object for the UI
        AbstractPane *root = qml->createRootObject();
    
        ArrayDataModel *model = new ArrayDataModel;
    
            if(------------->*\ file selected from qml /*<---------------){
              model->append(------------->*\String from QML/*<---------------);
            }    // Connect to list view and update modal
        ListView *listView = root->findChild("listview");
        listView->setDataModel(model);
    
        Application::instance()->setScene(root);
    }
    

    The string I want C++ comes from the filepicker on the main.qml

    // main.qml[...]attachedObjects: [
                FilePicker {
                    id: filePicker
    
                    property string selectedFile
    
                    mode: FilePickerMode.Picker
    
                    type: FileType.Other
                    title: "Open file..."
                    viewMode: FilePickerViewMode.Default
                    sortBy: FilePickerSortFlag.Default
                    defaultType: FileType.Other
                    onFileSelected: {
                        console.log("FileSelected signal recieved : " + selectedFiles);
                        selectedFile = selectedFiles[0];
                    }
                }
            ]
    

    Now, I did C++ functions to save the string:

    // Document.hppclass Document: public QObject {  Q_PROPERTY(QString document READ document WRITE setDocument NOTIFY documentChanged)
    
    public:  Q_INVOKABLE QString document();  Q_INVOKABLE void setDocument(QString &document);
    
    private:  QString m_document;}
    
    // Document.cpp
    
    QString Document::document(){
        return m_document;
    }
    
    void Document::setDocument(const QString &document){    if(document != m_document) {            m_document = document;            emit documentChanged(m_document);        }}
    

    Is this possible with this how to complete the string in the list view? Also how to make C++ know that the format was chosen among the filepicker so that it can add a new item to the list?

    Or do I have to go another way (for example by writing also the filepicker entirely in C++)?

    Here is an example, it uses a button rather than the FilePicker, but the mechanism is the same...

    Button {
        property int count: 0
        text: "Add item"
        onClicked: {
            count++
            theDataModel.append("button click " + count)
        }
    }
    
    ListView {
        dataModel: ArrayDataModel {
            id: theDataModel
        }
    
        [ ... ]
    }
    
  • Help to understand the basics of the integration of Javascript/QML

    Hey all!

    I am just development of BB for the first time, so please bear with me. I'm not sure that understand the interaction between JS and QML. I understand that you can write JS in QML, particularly in managers of signals, and I used chunks of it with success. Also, I show/read by the "Javascript in QML" and JS linked in the pages of Qt, which helped a bit.

    However, I am having a few problems incorporating it into my code.  Could you take a look at this and point me in the right direction? (I'm also new to JS itself, so maybe that my mistakes are with this instead?)

    onTriggered: {}

    When an item is selected, we push the recipe Page in the attribute of file chosenItem.

    var chosenItem = dataModel.data (row);

     

    Create the content page and place on top of drill down for it.

    contentPage var = pillDetailPageDefinition.createObject ();

     

    Set the properties of content to reflect the selected image.

    contentpage.contentImageURL = chosenItem.thumbnail

    contentpage.contentName = chosenItem.name + ', ' + chosenItem.mass

     

    * Errors begin to surface in this block *.

    contentpage.contentConsumption = {}

    Guide bar = "With"

    Mistakes of the top line: 'missing}, unknown symbol "guideline", missing colon "guideline", etc.

     

    Boolean multiInstruction = false;

    Top line errors: inconsistent input boolean expected RBRACE

                            

    If {(chosenItem.withFood)

    guideline += "food";

    multiInstruction = true;

    }

    If {(chosenItem.withWater)

    If (multiInstruction) guideline += 'and ';

    guideline += 'water '.

    }

    Return to the guideline;

    }

     


    Thanks in advance! I feel I'm missing something incredibly small/basic

    try calling it without braces.

    You can also create a function directly in QML, no need to export to a js file unless you want to use other components (that are not subcomponents) as well.

    to learn more about the construction of Qt/QML parent, I suggest to read this doc API:
    http://Qt-project.org/doc/Qt-4.8/objecttrees.html

    createObject (this) would create a new component with the parent defined on the object class, and if this is destroyed a new is also destroyed. This is useful when you create components dynamically as you don't have to delete them manually later.

  • Manipulate the object in another QML file

    I have a drop down menu with some functions that modify sldiers Beach

    onTriggered: {}

    Slide1.toValue = 10

    }

    It works fine, but when I move the piece that has the cursor in another qml file and include it like that...

    {MyInclude}

    }

    It stops working. Someone knows why, or how to fix it?

    One option is to give an id to MyInclude:

    MyInclude {
      id: myInclude
    }
    

    And reference it like this:

    myInclude.slide1.toValue = 10
    

    But it is better to create an alias of the upper level in MyInclude.qml property to define a public interface. Pseudo-code for MyInclude.qml:

    Page {
      property alias toValue: slide1.toValue
      ...
      Slider {
        id: slide1
      }
    }
    

    These alias properties can be referenced like this:

    myInclude.toValue = 10

    This is not limited to the alias properties, they can be of any type (int, var, etc.).

  • Abnormal display of the icons for items in the components window in jdev12.1.3

    After that I installed jdev12.1.3 in my computer with a Windows 7 64 bit, I got a window components looks like this:

    Components Window.JPG

    It seems that the components in the components window icons are abnormal, there should be different icons for different components.

    Can someone tell what is wrong with it?

    Thank you

    How much memory you have installed on the pc?

    Have you closed Jdev and he did it again?

    If so look at the messages window where you can get some info on the problem.

    A restart of the pc is sometimes useful.

    Timo

  • Install the components of the network on vSphere host via API NSX virtualization

    I want to install the components of the network on vSphere host via API NSX virtualization, can anyone help me?

    Hello

    What SDK NSX are you referring?

    I can confirm, that the next REST call will work to prepare the cluster hosts.

    POSTER https://nsx-mgr-ip/api/2.0/nwfabric/configure

    field-c11

    You will receive the in the http response.

    The job status can be asked here:

    https://NSX-Mgr-IP/api/2.0/services/taskservice/job/

    field - c11-> MoRef of the cluster you want to prepare. I guess you know how to get the MoRef in a Cluster.

    Don't forget basic authentication and the Content-Type: application / xml header

    I hope this helps

    Fab

  • collection master cs6 installed won't install all the components for photoshop, after effects, or FB and yet everything is fine

    collection master cs6 installed won't install all the components for photoshop, after effects, or FB and yet everything is fine

    Alanh61734259 summers - receive you specific error messages in the installation log files?  You can find details on how to locate and interpret logs troubleshooting installation with install newspapers | CS5.5, CS5, CS6, CC.  You are invited to post specific errors that you will discover in this discussion.

Maybe you are looking for