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. Setting multiple size to qtabbar
QtWS25 Last Chance

Setting multiple size to qtabbar

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.1k 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.
  • K Offline
    K Offline
    kitten
    wrote on last edited by
    #1

    hi
    i have a qtabwidget that has a qtabbar
    i want to set different sizes to any tabs
    how can i do that?

    www.kitten.mihanblog.com

    1 Reply Last reply
    0
    • L Offline
      L Offline
      ludde
      wrote on last edited by
      #2

      Have not tried it, but I would assume overriding the QTabBar::tabSizeHint() function would do the trick.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kitten
        wrote on last edited by
        #3

        can you give me some more information
        for example a bit code
        tnx

        www.kitten.mihanblog.com

        1 Reply Last reply
        0
        • L Offline
          L Offline
          ludde
          wrote on last edited by
          #4

          Sure. You have to create your own subclass of QTabBar, where you override tabSizeHint, something like this:
          @
          class TabBar : public QTabBar
          {
          Q_OBJECT
          public:
          explicit TabBar(QWidget *parent = 0) :
          QTabBar(parent)
          {
          }

          protected:
          QSize tabSizeHint(int index) const
          {
          QSize hint = QTabBar::tabSizeHint(index);

              if (index == 0)
                  return QSize(100, hint.height());
              else
                  return hint;
          }
          

          };
          @

          To make your tab widget use it, I think you have to subclass QTabWidget as well, something like this:
          @
          class TabWidget : public QTabWidget
          {
          Q_OBJECT
          public:
          explicit TabWidget(QWidget *parent = 0) :
          QTabWidget(parent)
          {
          setTabBar(new TabBar);
          }
          };
          @

          This will make the first tab of a TabWidget have width 100.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kitten
            wrote on last edited by
            #5

            thanks alot.
            it works so good for me

            www.kitten.mihanblog.com

            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