PDA

View Full Version : QTabBar adding tabs button "+"



alonso15
20th May 2011, 16:30
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
http://s1.postimage.org/a3n1n9heq/Sans_titre.png

Santosh Reddy
20th May 2011, 17:24
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.

alonso15
20th May 2011, 19:27
yes i have my own Tabbar but i don't know how to make this button plz i need some code

ChrisW67
20th May 2011, 22:46
If you want your image to show in the forum then upload it here rather than use a third party host.


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.