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. How to control TabBar width in MdiSubwindow
Forum Updated to NodeBB v4.3 + New Features

How to control TabBar width in MdiSubwindow

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.7k 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.
  • A Offline
    A Offline
    aungthetnaing
    wrote on last edited by
    #1

    I would like to title text in tabbed view mode of MDI subwindow to adjust to text length. Currently, it is too wide.

    Aung

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

      You can get hold of the underlying tabbar and call setExpanding(false) on it, see the "documentation":http://doc.qt.nokia.com/latest/qtabbar.html#expanding-prop

      The following example illustrates how this can be done:

      @

      #include <QtGui>
      int main(int argc, char **argv)
      {
      QApplication app(argc, argv);
      QMainWindow window;

      QMdiArea *area = new QMdiArea(&window);
      area->setViewMode(QMdiArea::TabbedView);
      QMdiSubWindow *first = area->addSubWindow(new QLineEdit(area));
      first->setWindowTitle("First");
      QMdiSubWindow *second = area->addSubWindow(new QLineEdit(area));
      second->setWindowTitle("Second");
      window.setCentralWidget(area);
      
      QList<QTabBar *> tabBarList = area->findChildren<QTabBar*>();
      QTabBar *tabBar = tabBarList.at(0);
      if (tabBar) {
       tabBar->setExpanding(false);
      

      }
      window.show();
      return app.exec();
      }
      @
      Does this give you the result you are looking for?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aungthetnaing
        wrote on last edited by
        #3

        I found that tabBar is accessible. However, visual result did not change after expanding() is set to false.

        Aung

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sigrid
          wrote on last edited by
          #4

          When running the example I pasted above, do the tabs adjust to the length of the text? If so, can you modify the example so that it shows your problem? Which version of Qt are you using and on which platform?

          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