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. [SOLVED] setStyleSheet() for tab in QTabWidget
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] setStyleSheet() for tab in QTabWidget

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 7.6k 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.
  • R Offline
    R Offline
    rizoritis
    wrote on last edited by
    #1

    Hello,

    I created a tab widget in QtDesigner and I am trying to make one of the tabs transparent to act as a spacer between my main tabs. I added the following line in the constructor of my MainWindow widget in attempt to do so:

    @ui->spacerTab->setStyleSheet("width: 1000px;" "color: transparent;" "background: transparent;");@

    For some reason nothing is happening. I even tried

    @ui->spacerTab->hide();@

    and that didn't do anything either. Is there a reason why I have no control over my spacerTab in my widget. Does anyone know of a simple way to add a spacer between a set of tabs. I do not want every tab to have a spacer just one between two groups of tabs that I have.

    Thanks

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

      what is the type of "ui->spacerTab"? is it QTabWidget?
      You should take a look at the "stylesheet reference":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar.

      --- 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
      • R Offline
        R Offline
        rizoritis
        wrote on last edited by
        #3

        [quote author="raven-worx" date="1372918890"]what is the type of "ui->spacerTab"? is it QTabWidget?
        You should take a look at the "stylesheet reference":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar.[/quote]

        spacerTab is a tab within my QTabWidget. I have wen through the documentation and examples and even if I copy and paste it does not work...

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

          you mean that this is the content widget of the tab right?
          AFAIK you can't name tabs...

          The only way you can style tabs (QTabBar) is with stylesheet's sub-controls, indicators and pseudostates:
          [quote]
          Individual tabs may be styled using the ::tab subcontrol. Close buttons using the ::close-button The tabs support the :only-one, :first, :last, :middle, :previous--selected, :next-selected, :selected pseudo states.

          The :top, :left, :right, :bottom pseudo states depending on the orientation of the tabs.

          Overlapping tabs for the selected state are created by using negative margins or using the absolute position scheme.

          The tear indicator of the QTabBar is styled using the ::tear subcontrol.

          QTabBar used two QToolButtons for its scrollers that can be styled using the QTabBar QToolButton selector. To specify the width of the scroll button use the ::scroller subcontrol.

          The alignment of the tabs within the QTabBar is styled using the alignment property.

          Warning:

          To change the position of the QTabBar within a QTabWidget, use the tab-bar subcontrol (and set subcontrol-position).
          [/quote]

          --- 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
          • R Offline
            R Offline
            rizoritis
            wrote on last edited by
            #5

            [quote author="raven-worx" date="1372938959"]you mean that this is the content widget of the tab right?
            AFAIK you can't name tabs...

            The only way you can style tabs (QTabBar) is with stylesheet's sub-controls, indicators and pseudostates:
            [quote]
            Individual tabs may be styled using the ::tab subcontrol. Close buttons using the ::close-button The tabs support the :only-one, :first, :last, :middle, :previous--selected, :next-selected, :selected pseudo states.

            The :top, :left, :right, :bottom pseudo states depending on the orientation of the tabs.

            Overlapping tabs for the selected state are created by using negative margins or using the absolute position scheme.

            The tear indicator of the QTabBar is styled using the ::tear subcontrol.

            QTabBar used two QToolButtons for its scrollers that can be styled using the QTabBar QToolButton selector. To specify the width of the scroll button use the ::scroller subcontrol.

            The alignment of the tabs within the QTabBar is styled using the alignment property.

            Warning:

            To change the position of the QTabBar within a QTabWidget, use the tab-bar subcontrol (and set subcontrol-position).
            [/quote][/quote]

            Yes, you are right, it is the content of a page within the QTabWidget. But, I do not want to reposition the entire tab bar. I want to reposition an individual tab to be separated by an inch or so from my main tabs. I dont think you can position individual tabs in the tab bar so I wanted a way to add a tab between and make that one transparent and non-clickable so that it gives the effect of a space between my tabs.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rizoritis
              wrote on last edited by
              #6

              Figured it out myself. I was missing placing it in a stylesheet:

              @this->setStyleSheet("QTabBar::tab:disabled {width: 1000px; color: transparent; background: transparent;}");@

              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