Important: Please read the Qt Code of Conduct -

QTabWidget - tab position.

  • Hi,

    I am working with QtabWidget.
    I need to implement some thing like : There should be two tabs, one tab should always be at the left most and another tab should always be at the right most of QtabWidget and rest of the tabs which will be added dynamically should be added between these two tabs.

    I am not sure whether the above is possible or not. If possible then how ?

    If anyone is having any idea?


  • Hii,
    Qt also provides QTabBar
    see here

  • Thanks for your response.

    But I need the tab should always be at the right most of the tabwidget or tabbar.
    If there are only two tabs , then one should be at the right most and another should b left most and there should be gap between them and if the third tab is added then it should be added between the two tabs.


  • I guess for that purpose you can create a list of QPushButton using QList<QPushButton*>

    From Docs:
    In QList<T> Items can be added at either end of the list using QList::append() and QList::prepend(), or they can be inserted in the middle using QList::insert(). More than any other container class, QList is highly optimized to expand to as little code as possible in the executable. QStringList inherits from QList<QString>.
    hope it helps.

  • I think the above will not solve my problem.
    I need something like only one tab in the tab widget should be added to the right most of the widget and rest of the tabs should be at the left.

    Do you have any idea about this?


Log in to reply