Results 1 to 3 of 3

Thread: AddTab button in QTabBar

  1. #1
    Join Date
    Jun 2010
    Posts
    4
    Thanks
    1

    Default AddTab button in QTabBar

    Hi,

    I need to add simple push or tool button to TabBar like in Opera or Firefox to add new tab I try with setTabButton

    Qt Code:
    1. QPushButton *m_addButton = new QPushButton("+", this);
    2. m_addButton->setObjectName("addButton");
    3. connect(m_addButton, SIGNAL(clicked()), this, SLOT(newTab()));
    4. QTabBar * tabBar = new QTabBar();
    5. tabBar->setTabButton(0, QTabBar::RightSide, m_addButton);
    To copy to clipboard, switch view to plain text mode 

    but this don't work - the button is behind the tabs

    How can I do this?

  2. #2
    Join Date
    Jun 2010
    Location
    India
    Posts
    50
    Thanks
    1
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: AddTab button in QTabBar

    Simple solution may be
    1. use QTabWidget & setCornerWidget function instead of using QTabBar.
    2. If you want to use QTabBar you have to create & draw your control or find the layout used and add your widget next to last item in the layout.

  3. The following user says thank you to agathiyaa for this useful post:

    ekapek (3rd July 2010)

  4. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: AddTab button in QTabBar

    If You want to add i.e. pushbutton INSIDE particular tab (not on the tab itself) do:
    add herizontal/vertical-layout inside tab, don't
    then
    Qt Code:
    1. ui->verticallayout->addWidget(m_addButton);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTabbar style ::scroller to expand the tab scoll button space.
    By AmolShinde_8 in forum Qt Programming
    Replies: 0
    Last Post: 22nd February 2010, 14:40
  2. QTabBar??
    By anupamgee in forum Qt Programming
    Replies: 12
    Last Post: 30th April 2009, 18:13
  3. Disable close button on QTabWidget/QTabBar
    By minimoog in forum Qt Programming
    Replies: 1
    Last Post: 16th March 2009, 05:25
  4. QTabWidget clicking problems after addTab()
    By DonSam in forum Qt Programming
    Replies: 0
    Last Post: 14th October 2008, 08:28
  5. QTabBar with optional button to the right of every tab
    By momesana in forum Qt Programming
    Replies: 13
    Last Post: 8th October 2007, 01:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.