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::expanding() feature
Forum Updated to NodeBB v4.3 + New Features

QTabBar::expanding() feature

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.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
    Algirdasss
    wrote on last edited by
    #1

    I derived QTabWidget class and tried to set expanding property on the tab bar. I expect tabs to stretch and take all tab bar space, but it seems that property does nothing. Do I misunderstand the meaning of this property or there is something wrong with implementation?

    Has anybody managed to use this property successfully??

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dguimard
      wrote on last edited by
      #2

      hello

      does the QTabWidget is wrapped into a dialog as well or did you set the sizepolicy ?

      setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));

      hope that it help,

      regards
      david

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

        My code:

        MainWindow.h

        @class MyTabWidget : public QTabWidget
        {
        public:
        MyTabWidget(){
        tabBar()->setExpanding(true);
        qDebug() << "EXPANDING IS " << tabBar()->expanding();
        }
        };

        class MainWindow : public QMainWindow
        {
        Q_OBJECT

        public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();

        protected:
        void changeEvent(QEvent *e);

        private:
        Ui::MainWindow *ui;
        };@

        MainWindow.cpp

        @MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {
        ui->setupUi(this);

        MyTabWidget *mtw = new MyTabWidget();
        mtw->addTab(new QWidget(), "Tab 1");
        mtw->addTab(new QWidget(), "Tab 2");
        
        this->setCentralWidget(mtw);
        

        }@

        Thats what Qt documentation says about that property:

        bq. expanding : bool
        This property holds when expanding is true QTabBar will expand the tabs to use the empty space.
        By default the value is true.
        This property was introduced in Qt 4.5.
        Access functions:
        bool expanding () const
        void setExpanding ( bool enabled )
        See also QTabWidget::documentMode.

        So as I uderstand, this property should work like this .... ??
        !http://picasaweb.google.com/lh/photo/ch2fTaNW6kb3_jnc2S0Low?feat=directlink()!

        1 Reply Last reply
        0
        • B Offline
          B Offline
          BlackDante
          wrote on last edited by
          #4

          maybe this would help:
          @class MyTabWidget : public QTabWidget
          {
          Q_OBJECT
          public:
          MyTabWidget(QTabWidget *parent = 0){
          tabBar()->setExpanding(true);
          qDebug() << "EXPANDING IS " << tabBar()->expanding();
          }
          };@

          sorry for my broken english :)

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Algirdasss
            wrote on last edited by
            #5

            Amm ... tested. No results. Do you think addition of Q_OBJECT macro may change something?

            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