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. QSS QTabBar text-align does not work
Forum Updated to NodeBB v4.3 + New Features

QSS QTabBar text-align does not work

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

    I try (font-weigth: works, but text-align: does not work):

    @QTabBar::tab:text{
    font-weight:bold;
    text-align:left;
    }@

    I try, but it was also not working:

    @QTabBar::tab {
    font-weight:bold;
    text-align:left;
    }@

    My QTabWidget:

    @<item>
    <widget class="QTabWidget" name="tabWidget">
    <widget class="QWidget" name="tab">
    <attribute name="title">
    <string>Tab 1</string>
    </attribute>
    </widget>
    <widget class="QWidget" name="tab_2">
    <attribute name="title">
    <string>Tab 2</string>
    </attribute>
    </widget>
    </widget>
    </item>@

    I also have not found any "property" (<property name="...">) that aligns the text.

    how to use the "QSS" to align the text of the tabs (QTabBar/QTabWidget) ?

    QT project: https://github.com/brcontainer/qt-helper

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

      i just checked (in Qt4): tabs don't support text alignment directly.
      The only possibility you can try is to set the text-alignment on the QTabBar instead of it's ::tab selectors.

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

        I try, but not working.
        @ QTabBar{
        text-align:left;
        }@

        what do I do? Thanks.

        QT project: https://github.com/brcontainer/qt-helper

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

          it was an idea. If this isn't working either i am afraid it isn't possible at all.
          Nevertheless you can do the painting yourself as a last resort.
          See QTabBar::paintEvent() for more details.
          And idea to do so would be to pass an style option object without the text and let the tabs be drawn by Qt. Then find out the "content rects" for each tab and draw your aligned text in there.

          But if its the first time you are doing this it will be a hard work i guess.

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

            Seems like a great idea, I'll try, even though I have not done this before I will not be so complex.

            But what is odd is to have a selector (QSS) to do that.

            I'll try

            QT project: https://github.com/brcontainer/qt-helper

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

              [quote author="Guilherme Nascimento" date="1386951146"]
              But what is odd is to have a selector (QSS) to do that.[/quote]
              For that simply define a (styleable) property which you then use in your painting code.

              --- 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

              • Login

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