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. QTabWidget size
Forum Updated to NodeBB v4.3 + New Features

QTabWidget size

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k 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
    BlackMamba
    wrote on 7 Oct 2013, 08:13 last edited by
    #1

    Hello,

    I have a QTabWidget with only 3 tabs and I would like that those tabs take the space of the lenght of the widget: Now I have :

    TTT
    XXXXXXXXXXXXX
    XXXXXXXXXXXXX
    XXXXXXXXXXXXX
    XXXXXXXXXXXXX

    And I would like

    xxxTxxxTxxxTxxx
    XXXXXXXXXXXXX
    XXXXXXXXXXXXX
    XXXXXXXXXXXXX
    XXXXXXXXXXXXX

    I know that I could do this with stylesheets for a given qtabwidget size but I dont know how I could do that it fits automatically if the qtabwidget size changes.

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NicuPopescu
      wrote on 7 Oct 2013, 11:47 last edited by
      #2

      Hi,

      after the tabwidget's stylesheet is loaded and applied you need to resize the tabbar in your code: I think you could do this in two ways, either by subclassing the QTabWidget and manipulate the tab bar inside(recommended) or as following:

      @ QTabBar tabBar = ui->tabWidget->findChild<QTabBar >(QLatin1String("qt_tabwidget_tabbar"));
      if(tabBar)
      {
      QPushButton
      button = new QPushButton();
      button->setFlat(true);
      button->setFixedWidth(200);
      button->setText(tabBar->tabText(0));
      tabBar->setTabText(0,"");
      tabBar->setTabButton(0, QTabBar::LeftSide,((QWidget
      )(button)));
      }@

      getting the tabbar in such way looks "unorthodox" but it works :)

      Cheers!

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BlackMamba
        wrote on 7 Oct 2013, 12:28 last edited by
        #3

        I wil try this out, thanks :)

        1 Reply Last reply
        0

        1/3

        7 Oct 2013, 08:13

        • Login

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