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. QTabBar: padding size inside tabs
Forum Updated to NodeBB v4.3 + New Features

QTabBar: padding size inside tabs

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 7.4k 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.
  • N Offline
    N Offline
    nowrep
    wrote on last edited by
    #1

    Hi,
    I have already created the same topic on qtcentre, but I never get answer there, so I am copying it there.

    Is it possible to get padding size inside of QTabBar's tab according to current style?
    I have an application running on Gnome, KDE, Windows. I use QTabWidget + QTabBar to show tabbed pages and I need to show close button + text + icon on some tabs and only icon on other tabs.
    So I need to set some fixed width to those icon only tabs. I'd like to achieve centering icon in tab on all platforms.
    The problem is, that every style has different left padding inside tab (look at attachement, black line = padding I want to know).
    Is there any way to get this padding? Something like QStyle:: pixelMetric()?

    If I know this size, it will be then very easy to calculate desired width for tab.

    Thanks for any help.

    !http://dl.dropbox.com/u/42835431/tabbar-margin-width.png(Tab margins)!

    As you can see from screenshot, this padding is very very small in KDE and quite significant in Gnome.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stevenceuppens
      wrote on last edited by
      #2

      Hi,

      maybe you can take a look at stylesheets!

      "stylesheet-reference":http://doc.qt.nokia.com/stable/stylesheet-reference.html
      "customizing-qtabwidget-and-qtabbar":http://doc.qt.nokia.com/stable/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

      Steven CEUPPENS
      Developer / Architect
      Mobile: +32 479 65 93 10

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nowrep
        wrote on last edited by
        #3

        Hi,
        unfortunately, this is not what I am looking for.
        If you use this code:

        @
        QTabBar::tab
        {
        padding: 0px;
        }
        @

        tabs will stop using application style.

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          Have a look at this "code snippet":https://developer.qt.nokia.com/wiki/CustomTabBar in the wiki.

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nowrep
            wrote on last edited by
            #5

            It would only help if the left button (QLabel in this case) was placed in the top left corner of tab (0,0).
            But this is not the case in Gnome (padding from screenshot), so when I set fixedWidth of QLabel to 35 and tabSizeHint width to 35 too, QLabel just don't fit in tab.

            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