Arguments for function addTab()



  • In our qml.main we have some code that is repeated multiple times with variations of course:

    [CODE]videoTab=makeTab("videoTab","Video", "video.qml",tabView.count)
    tabView.addTab(videoTab.name,videoTab.tab)[/CODE]

    I have searched for function makeTab() to no avail. Where can I find a description? Specifically I wish to see a description of property: videoTab.name.

    I have found that addTab() is an overloaded function and both of them have the same first argument. Here is one of the descriptions:

    [CODE\int QTabWidget::addTab(QWidget *page, const QIcon &icon, const QString &label)[/CODE]

    As I read that, the first argument is a pointer to a widget. In the working code, the example provided above, it looks like the name of the tab is being provided. To me, the name of the argument provided implies a string. If so then the argument provided does not match required argument type.
    What am I missing here?


  • Qt Champions 2017

    Hi
    [CODE] is ```
    and same for the end


  • Qt Champions 2017

    Hi
    The QML tabView seems to accept a string
    http://doc.qt.io/qt-5/qml-qtquick-controls-tabview.html#addTab-method



  • Hello mrjj,
    so that page shows the first arg as a string. This page:
    http://doc.qt.io/qt-5/qtabwidget.html
    is the one I get when I search from here:
    http://doc.qt.io/qt-5/search-results.html?q=addtab
    Under the section Public Functions I find this line:
    int addTab(QWidget *page, const QString &label)
    I will go with your page but ask for a suggestion as to how to find it with a search.

    On my Internet Explorer the CODE markers look like three apostrophies but that does not work. I used copy paste for this post. How might I type in those characters?


  • Qt Champions 2017

    @BKBK

    Hi you seems to have found
    tabWidget but the QML sample you talk about is using TabView so its other class :)
    ( i just searched for tabview)

    I never type them. i just use button :)
    alt text



  • @mrjj
    Never, ever noticed the button --- I always type the backticks in! :)

    @BKBK
    The characters are not "apostrophe"s (or "single-quote"s), they are "backtick"s! Depending on keyboard locale, the backtick (at least here in UK!) is on the key at the very top-left of the keyboard.


  • Qt Champions 2017

    @JonB
    hehe well i was like 2 years to discover that
    right click on class or variables in Creator and choose the
    refactor menu, have tons of features for adding virtual members,
    sync parameters change and generate get/setters for variables.
    :)



  • @mrjj
    I'm not a Qt Creator user, I'm a PyCharm (Python, PyQt) user. And yes that has all the refactoring stuff you mention. But I never use them --- I only ever use the "Rename"!



  • @mrjj
    Trying the backtick marker to delineate code in the next line
    const int MAX_SIZE = 480;
    Does that work as expected.
    I think this question is answered so am marking it as such. Just taking the opportunity to test that backtick thing.
    In the preview window it looks ok.


  • Qt Champions 2017

    @BKBK
    Almost correct, but you need to use 3 of them in start and end.

    const int MAX_SIZE = 480;
    

    IMAGE
    (image)



  • @mrjj Interesting, one looks good in the editor. Lets try one backtick on each end in the next line:
    const int MAX_SIZE = 480;
    and then three on each end in the next line:
    const int MAX_SIZE = 480;
    and see how that looks. I cannot see any difference in the preview pane. Maybe a difference will show up in the final post.


  • Qt Champions 2017

    @BKBK
    Hi
    you put them too close to the text. the code should be in between.

    const int MAX_SIZE = 480;
    

    alt text



  • @mrjj Too close to the text??? I do not understand your intent. When I typed each of the code lines I pressed the backtick key 1 or 3 times then immediately followed it with letters "const" that began the line of code. From my view, using Internet Explorer through a government firewall, both lines look exactly the same and both are nicely highlighted with red font to indicate they are lines of code.


  • Qt Champions 2017

    @BKBK
    But code is NOT red. that is other form of highlighting.

    Please try the </> button and you will see what i mean.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.