Results 1 to 4 of 4

Thread: QTabBar adding tabs button "+"

  1. #1
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QTabBar adding tabs button "+"

    please i need help
    i'd like to have a button in my navigator in the tabbar and when i click on it i have new tab
    my problem is in the button how i can create it .
    this button should be like a tab (like firefox, opera ...) and never moves

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QTabBar adding tabs button "+"

    You may need to create you own custom TabBar, by inherting it, and adding more features to it.

    add more implementation relavent to mouseEvents, paintEvent, etc.. on top of exsisitng TabBar.

  3. #3
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTabBar adding tabs button "+"

    yes i have my own Tabbar but i don't know how to make this button plz i need some code

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTabBar adding tabs button "+"

    If you want your image to show in the forum then upload it here rather than use a third party host.

    Quote Originally Posted by alonso15 View Post
    i'd like to have a button in my navigator in the tabbar and when i click on it i have new tab
    my problem is in the button how i can create it .
    this button should be like a tab (like firefox, opera ...) and never moves
    If it should look like a tab then I'd start by making it a tab.

    Add a tab with the tabText() "+" as the last tab. When the currentChanged() is emitted with the "+" tab index then insertTab() a new tab before the "+" tab, i.e as the second-last tab, then switch to it. This approach works but becomes awkward for the user when the tab bar starts scrolling. If you put the "+" tab first then it will never scroll off-screen.

    If you put the tab bar and a "+" QPushButton in a horizontal layout then you can have a permanent add tab button independent of the tab bar scrolling but you lose the automatic "looks like a tab" and it is always positioned far-right (or left).

    BTW: The button in Firefox moves to accommodate the new blank page.

Similar Threads

  1. Replies: 3
    Last Post: 8th December 2011, 19:21
  2. Replies: 0
    Last Post: 20th September 2010, 09:58
  3. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  4. How to make "west" tabs horizontal?
    By plumbum in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2007, 10: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.