Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    4
    13
    5485
    Loading More Posts
    • 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.
    • T
      tomuse last edited by

      Hi all,

      All my question is in the title :)

      Thanks in advance for your help.
      Thomas.

      1 Reply Last reply Reply Quote 0
      • M
        mlong last edited by

        I don't know that you can get that specific with CSS, but I'm sure if someone knows an answer they'll post it. If so, I'd be interested in seeing how, myself.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply Reply Quote 0
        • A
          andre last edited by

          Well, QSS allows you to set any property on the widgets you're styling. That includes setting the orientation, I'd think.

          1 Reply Last reply Reply Quote 0
          • K
            KA51O last edited by

            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 Reply Quote 0
            • T
              tomuse last edited by

              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 Reply Quote 0
              • A
                andre last edited by

                [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 Reply Quote 0
                • K
                  KA51O last edited by

                  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 Reply Quote 0
                  • T
                    tomuse last edited by

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

                    1 Reply Last reply Reply Quote 0
                    • A
                      andre last edited by

                      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 Reply Quote 0
                      • T
                        tomuse last edited by

                        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 Reply Quote 0
                        • K
                          KA51O last edited by

                          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 Reply Quote 0
                          • A
                            andre last edited by

                            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 Reply Quote 0
                            • K
                              KA51O last edited by

                              Hmm, you may be right.

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post