QTabBar::expanding() feature



  • 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??



  • 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



  • 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()!



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.