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. CSS padding inside QTabWidget tabs hiding text
QtWS25 Last Chance

CSS padding inside QTabWidget tabs hiding text

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtabwidgetqtabbarcss
6 Posts 4 Posters 2.4k Views
  • 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.
  • D Offline
    D Offline
    drdydx
    wrote on 25 Oct 2015, 17:19 last edited by drdydx
    #1

    Hi everyone

    I'm making an application which uses a QTabWidget which I would like to customise with CSS. The text in each tab can be quite long (an absolute file path) and I would like it to be truncated so that the tabs stay at a reasonable size. To achieve this I'm using setElideMode, which works fine for CSS styled tabs as long as there is no padding.

    Here is an image so you can see what's going on:
    alt text

    The first two tabbars are without padding, and in the second one the tabbar is shorter and the text is elided correctly. In the secont pair 5px padding is added but the text elide is still caculated as if there were no padding. This is causing the text that overlaps with the padding to be hidden.

    Is there any way to make the text display properly between the padding at either side? I know I can override paintEvent for my tabbar altogether but I was hoping there is an easier solution. Any suggestions are welcome, thanks in advance!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 25 Oct 2015, 18:19 last edited by Chris Kawa
      #2

      That's definitely a bug. There seems to be a bug report about it QTBUG-15203, but it has been closed due to Qt4 EOL. Since it's still valid please report it for Qt5.

      As for a workaround I'm afraid you will need to paint the tabs yourself. If you don't wan't to subclass and override paintEvent you can install an event filter and handle the painting there. Other that that I can't think of any other solution, apart maybe from adding some spaces to the front of the strings :P (just kidding, don't do it).

      Q 1 Reply Last reply 11 Nov 2019, 09:21
      2
      • C Chris Kawa
        25 Oct 2015, 18:19

        That's definitely a bug. There seems to be a bug report about it QTBUG-15203, but it has been closed due to Qt4 EOL. Since it's still valid please report it for Qt5.

        As for a workaround I'm afraid you will need to paint the tabs yourself. If you don't wan't to subclass and override paintEvent you can install an event filter and handle the painting there. Other that that I can't think of any other solution, apart maybe from adding some spaces to the front of the strings :P (just kidding, don't do it).

        Q Offline
        Q Offline
        qwasder85
        wrote on 11 Nov 2019, 09:21 last edited by
        #3

        @Chris-Kawa This is still not fixed and the solution you added as a joke sounds more and more tempting to me...

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 11 Nov 2019, 11:47 last edited by
          #4

          See also https://bugreports.qt.io/browse/QTBUG-6905 - feel free to provide a fix for it, we're happy to review it :)

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          C 1 Reply Last reply 11 Nov 2019, 12:49
          0
          • C Christian Ehrlicher
            11 Nov 2019, 11:47

            See also https://bugreports.qt.io/browse/QTBUG-6905 - feel free to provide a fix for it, we're happy to review it :)

            C Offline
            C Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on 11 Nov 2019, 12:49 last edited by
            #5

            @Christian-Ehrlicher There are also QTBUG-50637, QTBUG-48994, QTBUG-30722, which are all the same issue reported over and over again. If you read the comments on the first one I tried to provide a fix, but it was bad (fixed one thing, broke another). Then Andy provided a patch that worked great as far as I can tell aaaand nothing happened. For whatever reason the patch never got through and the last comment on it is "I will try to get to it this week", which was a year ago ;)

            C 1 Reply Last reply 11 Nov 2019, 17:37
            0
            • C Chris Kawa
              11 Nov 2019, 12:49

              @Christian-Ehrlicher There are also QTBUG-50637, QTBUG-48994, QTBUG-30722, which are all the same issue reported over and over again. If you read the comments on the first one I tried to provide a fix, but it was bad (fixed one thing, broke another). Then Andy provided a patch that worked great as far as I can tell aaaand nothing happened. For whatever reason the patch never got through and the last comment on it is "I will try to get to it this week", which was a year ago ;)

              C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 11 Nov 2019, 17:37 last edited by
              #6

              @Chris-Kawa Maybe you can ping @AndyS again so we can take a look on it. I had no time for it to think about an own patch.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              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