Add a tab dynamically in C++ or QML (with QML existing as the content of the tab)

Hello

I'm trying to dynamically add a tab in an existing TabbedPane.  I am able to do that through C++ with:

Page* page = Page::create();
Tab* tab = Tab::create().title("title").description("description");
tab->setContent(page);
app->tabbedPane->add(tab);

.. .but I don't want to add an empty Page.  I want to instantiate a document QML existing as content tab, in the same way that I defined the first tab in QML:

Tab {
     id: defaultTab
     objectName: "defaultTab"
     title: "title"
     CMLocationView {
     }
}

Is this possible in C++?  In QML?  In both?

Thank you!

In QML

TabbedPane {
    id: tabbedPane
    ...
    attachedObjects: [
        ComponentDefinition {
            id: pageDefinition
            source: "asset:///UI.qml"
        }
    ]
    function newTab() {
        var c = "import bb.cascades 1.0; Tab{}";
        var tab = Qt.createQmlObject(c,tabbedPane,"newTab")
        tab.content = pageDefinition.createObject(tab);
        tabbedPane.add(tab)
    }
}

My little demo here

https://github.com/congdanhqx/BB10-example/tree/master/tab-demo

Tags: BlackBerry Developers

Similar Questions

  • Dynamically new tabs, add a tab with a button pane

    In most modern browsers, it is very easy and intuitive how to open a new tab in the same window.
    Usually, there is a small button with a "+" to the right of the tabs. When you click this button, a new tab is created and it receives focus.

    What is the easiest way to mimic this behavior in a JavaFX application?. I think trying to add a tab 'false' with a sign «+» Then I know when this tab is clicked, and on this event, I could dynamically create a new tab and give it focus.
    What is the right way to do it? A small example of how best to implement it would be greatly appreciated.

    This seems to work ok:

    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Tab;
    import javafx.scene.control.TabPane;
    import javafx.scene.layout.AnchorPane;
    import javafx.stage.Stage;
    
    public class TabPaneWithAddButton extends Application {
    
      @Override
      public void start(Stage primaryStage) {
        final AnchorPane root = new AnchorPane();
        final TabPane tabs = new TabPane();
        final Button addButton = new Button("+");
    
        AnchorPane.setTopAnchor(tabs, 5.0);
        AnchorPane.setLeftAnchor(tabs, 5.0);
        AnchorPane.setRightAnchor(tabs, 5.0);
        AnchorPane.setTopAnchor(addButton, 10.0);
        AnchorPane.setLeftAnchor(addButton, 10.0);
    
        addButton.setOnAction(new EventHandler() {
          @Override
          public void handle(ActionEvent event) {
            final Tab tab = new Tab("Tab " + (tabs.getTabs().size() + 1));
            tabs.getTabs().add(tab);
            tabs.getSelectionModel().select(tab);
          }
        });
    
        root.getChildren().addAll(tabs, addButton);
    
        final Scene scene = new Scene(root, 600, 400);
        scene.getStylesheets().add("tabs.css");
        primaryStage.setScene(scene);
        primaryStage.show();
    
      }
    
      public static void main(String[] args) {
        launch(args);
      }
    }
    

    with the css (tabs.css) file:

    @CHARSET "US-ASCII";
    
    .tab-header-area {
      -fx-padding: 0 0 0 50 ;
    }
    
  • How to eliminate the Yahoo go up when I add a tab in the browser.

    by clicking on the '+' to add a tab in the browser is always appear a Yahoo home page. How can I change this?

    Hi, try this: Type Subject: config in the address bar, press ENTER, accept the warning, scroll to browser.newtab.url and make sure that 'Value' is defined Subject: newtab (right click > change, change it if necessary, taking care to not to change what anyone else). You will then need to restart Firefox.

    As an alternative, you can use the add-on SearchReset.

    If the problem returns, try Mode without failure of Firefox to see if it goes away. Firefox Safe mode is a troubleshooting mode that temporarily disables hardware acceleration, restores some settings and disables add-ons (extensions and themes).

    If Firefox is open, you can restart Firefox Safe mode in the Help menu:

    • Click the menu button

      click Help

      then select restart with disabled modules.

    If Firefox does not work, you can start Firefox in Mode safe as follows:

    • On Windows: Hold down the SHIFT key when you open the desktop Firefox or shortcut in the start menu.
    • On Mac: Hold the option key during the startup of Firefox.
    • On Linux: Exit Firefox, go to your Terminal and run firefox-safe-mode
      (you may need to specify the installation path of Firefox for example/usr/lib/firefox)

    When the Firefox Safe Mode window appears, select "start mode safe."

    If the problem is not present in Firefox Safe Mode, your problem is probably caused by an extension, theme or hardware acceleration. Please follow the steps described in the section Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems to find the cause.

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before you open Firefox for normal use again.

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    If you're still having problems, you can try these free programs to search for malicious software that work with your existing anti-virus software:

    Microsoft Security Essentials is a good permanent antivirus for Windows 7/Vista/XP, if you do not already have one. Windows 8 already has integrated antivirus.

    More information can be found in the article troubleshooting Firefox problems caused by malware .

    This solve your problems? Please report to us!

  • I have NO clickable "add a tab" function-NOT +, capacity no. new tab. How to do this?

    I do not have a sign to the right of the window of FF +. I have NO way of mouse-able of adding a tab. I can't customize a toolbar to add a "Add a tab" icon (only a new window, I would never want to.).
    I'm so disappointed.

    You can drag the new tab and symbol that you will find on the toolbar tabs on another toolbar, and it will become the button new ordinary tab as present in older versions of Firefox that I posted above.

    Open the Customize via "view > toolbars > customize" or "Firefox > Options > toolbars."

  • Cannot add new tab to look for something else while having another page up?

    I can't add new tabs to have different Web sites to the top at the same time, I click on add new tab and nothing happens. I have to do a whole new window please help?

    If you have the Ask toolbar, try to disable or uninstall.

    Tools > Modules > Extensions

  • How can I add a tab App when my laptop is not an option to control-click?

    In order to add a tab app, the news site said right click/Control-click on the tab, which opens a menu, from which you can designate it as a tab app. However, on my Mac, there is no control-click/right click I can find - so I can't do the app tabs. Is there another way to get around this? Is there another way to make tabs of the app? Am I missing something?

    See:

  • I can't add new tabs to my window, or by clicking on the little + on the right of the last tab or CTL T or the new file tab. This problem was recently

    1. Question

    I can't add new tabs to my window, or by clicking on the little + on the right of the last tab or CTL T or the new file tab. This problem was recently

    The Ask toolbar is initially only in versions of Firefox 3.6.x. uninstall this extension.

    There are a few places to check for the Ask toolbar:

  • Cannot add new tabs, or from the file menu or by clicking on the sign more (+) sign...

    Since I updated to v3.6.13, I can't add another tab by clicking on the sign Plus (+) sign or going to the file menu and clicking on new tab. The only way that a new tab is created is if you are on a site that opens a link in a new tab... I never had this problem before...

    Try to uninstall the Ask toolbar and it should work again. There is a compatibility issue with the Ask toolbar and the current version of Firefox.

  • How to add a tab before the placeholder separator (1, 2-3) for an independent (from markers) index for a document (book, a document in the book, not)?

    I use Framemaker 11

    Normally, for an index standard for a book, I add a tab before the separator placeholder (1, 2-3) to reach the following of my index format. The tab is added to the reference page before the "1: 2-3" and it translates back to the body page and then easily apply the paragraph format, I can add a dashed line (see results below)

    Text stream (note the before tab '1, 2-3'result obtained with formatting illustrated )
    1.PNG2.png


    However, when I try to do the same thing for an independent index of manufacturers, he can't. I can add the tab before the placeholder separator "1, 2-3", but she does not return to the body page. Is there a way to achieve the same formatting (right dotted tab) for a stand-alone markers index?

    Works for me. You choose the special > Index of > markers for re - generate the IOM file after setting things for tabs?

  • How to add a tab to the node root tree of inventory?

    Is it possible to add a tab for the node root tree in the display of the inventory? Something like InventoryView.VCenter?

    Thanks in advance,

    Derek

    InventoryView.RootFolder is probably what you want.

  • How to add new tabs to custome page

    Hello
    I created a new custom page
    now, I want to add new tabs to this page
    and desire to give the link to this tabs to other pages
    Server

    HA,

    The easiest way is to create a menu & even join page. Another approach is to create throught Jdeveloper, embedded in the Page of the OFA.

    Kind regards
    GYAN

  • How to make a page QML figurentsur only the first launch

    How to make a qml page appears only on the first time the application is started?

    I need to create a tabbed pane and the number of tabs depends on n the input from the user to whom it provides the first launch. How to make this happen?

    You can use QSettings to store parameters.

    Create two main qmls (mainHasInput.qml and mainHasNoInput.qml). When the user runs your application for the first time, load mainHasNoInput.qml. If the user enters the input values correct, who writes in your QSettings. The next time that the launch of the app, you check if a setting has been stored in your QSettings. If not, show your mainHasNoInput.qml, if yes, see the mainHasInput.qml (which is your main 'normal' screen)

    for an example how to use QSettings, see https://developer.blackberry.com/native/sampleapps/ -> 'persistent objects '.

  • Creating a dynamic form that would reveal a second "layer" of the form.

    I am looking to create a form that if need an additional request can be consulted and seen that if turned on by button or a certain type of trigger. The second part of the form would also require the choice of answers or fill in the fields. Is this possible? I need to keep it as a form/page, because it must be printed on the receiving end once it is filled. I can do the thing layer but I'm looking to make it easy for a user NOT easily fill the form and send it. Let me know what you think.

    Yes, it can be done. A button can be set up to show a layer, as well as hidden fields.

    Add a button, make the layer visible through the layers panel and then go to properties of the button Actions tab and add a new trigger to mouse to the top. Then select the command "Set layer visibility. You can also use the "show/hide a command" to view fields associated with this layer, under the same trigger.

  • Try to add a page to a pages document. It worked until now but just finished page 13 with text and photos and cannot add another page, using macbook pro with El Capitan and the most recent version of the Pages.

    Try to add a page to a pages document. It worked until now but just finished page 13 with text and photos and cannot add another page, using macbook pro with El Capitan and the most recent version of the Pages.

    You have placed your beam to insert at the end of your text on page 13 and then apply Insert menu: Page Break? In the v5.6.2, Pages I just add a new page to a section of four pages to this approach.

  • Looking for an add-on for FF button that launches TB (or any application). The add-on GetMailPlus I used is now broken

    There are several add-ons for FF to launch specific applications. A generic "Push the button, launch any application" would be more useful. Surely, this already exists?

    Hi, take a look at the buttons of toolbar - if it is not what you want, you can create one!

    If your question is resolved by this or another answer, please take a minute to let us know. Thank you.

Maybe you are looking for

  • AIRPod for iPhone 6

    The AirPod will work with the iPhone 6?

  • Firefox 13 will not load video

    13 Firefox won't charge not video - live stream - websites - other browser - says can not connect

  • Compatible with this PC webcam?

    Hi I want a webcam for my PC its CQ1140UKy 64 bit windows7 operating system There are many on the market, but I would like to know is it special, the one that works best with this PC or one will be ok? eplim x 500

  • The front panel ThinkCentre M81 connector pinout

    I have a ThinkCentre M81. I am currently trying to put the guts of it in another case, so that I can add some more to it. I checked all the guides I can find on Lenovo's Support site and they show only the location of the connector and how repalce th

  • Check the HP PSC 1210 ink levels

    I have a HP PSC 1210 with a HP Pavilion G6 running Windows 7.  How can I check my ink level? It used to be the HP Toolbox, but that has disappeared. Thank you