Adding a button to a tab row
-
Hello everyone,
I was wondering if it is possible to add a button to the QTabWidget tab row. I have a 'new tab' button that works great, but it floats above the TabWidget and thus uses up a lot of valuable screen space. I want my UI to have a very clean feeling and have no buttons above the TabWidget. I was hoping to place the new tab button in line with the tabs like the new tab buttons in Chrome or Firefox. The button will obviously have to move right as I add more tabs. As an extra bonus, it would be neat if the button looked like a miniature tab, but that is not critical.
So basically what I am asking for is:
a button that sits right next to the tab row and moves (as in Firefox and Chrome)code examples/links to working (simple) examples would be much appreciated.
Thanks so much for your help!
-
not to be pushy but some help would be greatly appreciated!
-
-
a possibility would be to actually insert an actual tab (and ensure that that tab is the last tab all the time) and every time the tab is activated you insert a new tab right before and show this one.
If this approach "flickers" you need to filter the mouse events for the last tab. You can use QTabBar::tabAt() for this and insert the tab without even activating the insertion-tab.
Also you will have to filter the key events on the QTabBar to make sure the user can't activate the tab with the left and right keys.
Also if you want you can "style":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar the last tab in a special way with stylesheets. (using QTabBar::tab:last {} )
-
Thanks raven-word, thats more of what Im looking for. Could you possibly provide some example code? What about using a QToolButton instead of a tab? would that be practical and how could I do it?
-
Here is exactly for you -- http://stackoverflow.com/a/27127109/867349
[quote author="nicky j" date="1389470758"]Thanks raven-word, thats more of what Im looking for. Could you possibly provide some example code? What about using a QToolButton instead of a tab? would that be practical and how could I do it?[/quote]
-
Here is exactly for you -- http://stackoverflow.com/a/27127109/867349
[quote author="nicky j" date="1389470758"]Thanks raven-word, thats more of what Im looking for. Could you possibly provide some example code? What about using a QToolButton instead of a tab? would that be practical and how could I do it?[/quote]