Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding a button to a tab row
Forum Updated to NodeBB v4.3 + New Features

Adding a button to a tab row

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 4.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicky j
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nicky j
      wrote on last edited by
      #2

      not to be pushy but some help would be greatly appreciated!

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hareen Laks
        wrote on last edited by
        #3

        Hope "this":http://stackoverflow.com/questions/19975137/how-can-i-add-a-new-tab-button-next-to-the-tabs-of-a-qmdiarea-in-tabbed-view-m will help you.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          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 {} )

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nicky j
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • T Offline
              T Offline
              troyane
              wrote on last edited by
              #6

              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]

              1 Reply Last reply
              0
              • T Offline
                T Offline
                troyane
                wrote on last edited by
                #7

                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]

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved