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. How to get all the tabs on left or right of the selected tabs using CSS?
Forum Updated to NodeBB v4.3 + New Features

How to get all the tabs on left or right of the selected tabs using CSS?

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 6.2k 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.
  • K Offline
    K Offline
    KA51O
    wrote on last edited by
    #4

    Did you already have a look at "this":http://developer.qt.nokia.com/doc/qt-4.8/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar ?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tomuse
      wrote on last edited by
      #5

      Of course I already had a look at the reference.
      The thing is QTabBar::tab:selected and QTabBar::tab:!selected allows you to modify the properties of selected and non-selected tabs, QTabBar::tab:next-selected and QTabBar::tab:previous-selected allows you to modify the properties of tabs closed to the selected tab.
      So I wonder if there is a trick to modify the properties of all the tabs on left or right of the selected tab.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #6

        [quote author="KA51O" date="1330499953"]Did you already had a look at "this":http://developer.qt.nokia.com/doc/qt-4.8/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar ?[/quote]

        Did you? Where in there is there an example of the feature that tomuse asked for?

        @tomuse:
        Did you spot this: http://developer.qt.nokia.com/doc/qt-4.8/stylesheet-syntax.html#setting-qobject-properties
        I checked the Qt source, and QTabWidget::tabPosition is such a property. That means it is stylable using the syntax above.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KA51O
          wrote on last edited by
          #7

          Well basically all tabs on the left and right of the selected tab are all tabs except the selected...
          so you can set the settings for all tabs the way you want and have a special look for the selected, or am I missing something ?

          Edit: Ok I get it, you just want the ones on the left OR the ones on the right... Sorry I missread that.
          Maybe you can do this by looping over your tabWidget and for each tab left of the selected(i.e. index smaller than the index of the selected tab) set a special style.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tomuse
            wrote on last edited by
            #8

            Could be a solution but I guess I cannot do this directly in a CSS file...

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #9

              Ah, well, actually, I misunderstood. I thought the question was to change where the tabs would appear: to the left (west), to the right (east) on the top (north) or on the bottom (south) of the widget using CSS. However, the question was how to differently style the different tabs to the left of the current tab than the ones to the right. That is a different question. Again, sorry, I misread the question.

              I don't think that that is possible, at least not without a lot of trickery. There is no property you can use to style on. The only hack I can come up with, is to use a proxy style and abuse a property you can use (enabled comes to mind) from the proxy. Basically, you would modfy the style option to say that any tab to the left of your current one is disabled using a QProxyStyle subclass. Then, you can use CSS to render the disabled ones (left ones) differently than the other tabs. Because the tabs are not really disabled, the tabwidget would still work as normal. Obviously, if you really have disabled tabs, this won't work, and I'm not sure the approach will work at all.

              Edit: because tabs are not widgets, I don't think you can set a style per-tab.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tomuse
                wrote on last edited by
                #10

                Thanks for your answer Andre.
                I also thought about a QProxyStyle, but too tricky :)
                I'll settle for applying the same style for all the non-selected tabs.

                Thanks for your help guys!

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  KA51O
                  wrote on last edited by
                  #11

                  bq. Edit: because tabs are not widgets, I don’t think you can set a style per-tab.

                  I think you could do it, but one would have to reimplement QTabWidget and QTabBar to have your own handling for the currentChanged() signal in QTabBar where one would then first get the tabButton using QTabBar::tabButton(int index, ButtonPosition position ) to get the single tabButton widgets and set the desired styles for them. The custom QTabBar must be set as the tabbar of the custom QTabWidget.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #12

                    I think the tabButton is something different: it is a button you can put on the tab (usually to close it). It is not the tab itself, but I might be off here... AFAIK, the tabs themselves are not buttons, but are rendered directly by the style using QStyle::drawControl and the CE_TabBarTab flag.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      KA51O
                      wrote on last edited by
                      #13

                      Hmm, you may be right.

                      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