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 can I set background color/image specific tab at QTabWidget?
Forum Updated to NodeBB v4.3 + New Features

How can I set background color/image specific tab at QTabWidget?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 8.8k 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.
  • C Offline
    C Offline
    cihanpesend
    wrote on last edited by
    #1

    Hi to everyone!
    After the long visitor status, finally, this is my first post.
    I create tabs dynamically in my TabWidget(from config). Like;
    -it is python code, pyqt, answers can be coded c++, dosn't matter for me :) -

    @baseWidget = QWidget()
    //fill baseWidget with other widgets
    window.tabWidget.addTab(baseWidget, _fromUtf8(""))
    window.tabWidget.setTabText(window.tabWidget.indexOf(baseWidget), ...)@

    Then, style via qss, like;

    @QTabBar::tab {}
    QTabBar::tab:selected {}
    QTabBar::tab:!selected {}
    QTabBar::tab:last {}
    QTabBar::tab:first:!selected {}
    QTabBar::tab:!selected:hover {}@

    At this point everything is OK. But, i want to colorize my tabs individually.

    How can i achieve this?
    If it is possible, how can set objectName for a tab?

    All post will be appreciated :)

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cihanpesend
      wrote on last edited by
      #2

      To imagine clearly,
      my result; !http://bugreports.qt-project.org/secure/attachment/30592/tabbar_stylesheet.png(created ui)!
      wanted; !http://bugreports.qt-project.org/secure/attachment/30591/tabbar_wanted.png(wanted ui)!

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jake007
        wrote on last edited by
        #3

        You can use class name as id (#) in css.

        for example:
        @QWidget#ozelterTab { background: orange; }
        QWidget#gunlukAnalizTab { backgroud: blue; }
        ...@

        I saw it once in an example. It worked there, but never tried it myself.


        Code is poetry

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cihanpesend
          wrote on last edited by
          #4

          [quote author="Jake007" date="1356614068"]You can use class name as id (#) in css.

          for example:
          @QWidget#ozelterTab { background: orange; }
          QWidget#gunlukAnalizTab { backgroud: blue; }
          ...@

          I saw it once in an example. It worked there, but never tried it myself.[/quote]

          I use # selector for other widgets, if i am able to set objectName.
          But here i cant set an objectName for individual tab !

          i tried ,
          @basewidget.setObjectName("blablabla")
          @
          didn't work :(

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cihanpesend
            wrote on last edited by
            #5

            Is it possible via subclassing QTabBar or QTabWidget ?

            1 Reply Last reply
            0
            • C Offline
              C Offline
              cihanpesend
              wrote on last edited by
              #6

              Anyone here ???

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lgeyer
                wrote on last edited by
                #7

                That's not possible out of the box.

                And immediate solution the springs to mind is to provide a QProxyStyle, which draws the tabs the way you like it (you will need a custom drawing method anyways for the style you want).

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  cihanpesend
                  wrote on last edited by
                  #8

                  First, thanks for your reply Lukas, i was really on tenterhooks

                  1-) can i say that it is imppossible with qss ?
                  2-) out of style, how i achieve to point a random tab for other purposes ?
                  3-) and most important, where can i find a extensive proxymodel example ?

                  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