Source Code (Use browser search to find items of interest.)

Class Index

qt'QTabBar (./qt-2.1.0/src/widgets/qtabbar.h:67)

class Q_EXPORT QTabBar: public QWidget
{
    Q_OBJECT
    Q_ENUMS( Shape )
    Q_PROPERTY( Shape shape READ shape WRITE setShape )
    Q_PROPERTY( int currentTab READ currentTab )
    Q_PROPERTY( int keyboardFocusTab READ keyboardFocusTab )

public:
    QTabBar( QWidget * parent = 0, const char *name = 0 );
   ~QTabBar();

    enum Shape { RoundedAbove, RoundedBelow,
		 TriangularAbove, TriangularBelow };

    Shape shape() const;
    virtual void setShape( Shape );

    void show();

    virtual int addTab( QTab * );
    virtual int insertTab( QTab *, int index = -1 );
    virtual void removeTab( QTab * );

    virtual void setTabEnabled( int, bool );
    bool isTabEnabled( int ) const;

    QSize sizeHint() const;
    QSizePolicy sizePolicy() const;

    int currentTab() const;
    int keyboardFocusTab() const;

    QTab * tab( int );

    virtual void layoutTabs();

public slots:
    virtual void setCurrentTab( int );
    virtual void setCurrentTab( QTab * );

signals:
    void  selected( int );

protected:
    virtual void paint( QPainter *, QTab *, bool ) const; // ### not const
    virtual void paintLabel( QPainter*, const QRect&, QTab*, bool ) const;

    void focusInEvent( QFocusEvent *e );
    void focusOutEvent( QFocusEvent *e );

    virtual QTab * selectTab( const QPoint & p ) const;
    void updateMask();

    void resizeEvent( QResizeEvent * );
    void paintEvent( QPaintEvent * );
    void mousePressEvent ( QMouseEvent * );
    void mouseReleaseEvent ( QMouseEvent * );
    void keyPressEvent( QKeyEvent * );

    QList<QTab> * tabList();

private slots:
    void scrollTabs();

private:
    QList<QTab> * l;
    QList<QTab> * lstatic;
    void makeVisible( QTab* t  );
    void updateArrowButtons();
    QTabPrivate * d;

private:	// Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
    QTabBar( const QTabBar & );
    QTabBar& operator=( const QTabBar & );
#endif
};


qt'QTabBar::QTabBar() (./qt-2.1.0/src/widgets/qtabbar.cpp:143)

QTabBar::QTabBar( QWidget * parent, const char *name )
    : QWidget( parent, name )
{
    d = new QTabPrivate;
    d->id = 0;
    d->focus = 0;
    d->a = new QAccel( this, "tab accelerators" );
    d->s = RoundedAbove;
    d->scrolls = FALSE;
    d->leftB = new QToolButton( LeftArrow, this );
    connect( d->leftB, SIGNAL( clicked() ), this, SLOT( scrollTabs() ) );
    d->leftB->hide();
    d->rightB = new QToolButton( RightArrow, this );
    connect( d->rightB, SIGNAL( clicked() ), this, SLOT( scrollTabs() ) );
    d->rightB->hide();
    l = new QList<QTab>;
    lstatic = new QList<QTab>;
    lstatic->setAutoDelete( TRUE );
    setFocusPolicy( TabFocus );

    connect( d->a, SIGNAL(activated(int)), this, SLOT(setCurrentTab(int)) );
}


/*!
  Destroys the tab control, freeing memory used.
*/


qt'QTabBar::~QTabBar() (./qt-2.1.0/src/widgets/qtabbar.cpp:171)

QTabBar::~QTabBar()
{
    delete d;
    d = 0;
    delete l;
    l = 0;
    delete lstatic;
    lstatic = 0;
}


/*!
  Adds \a newTab to the tab control.

  Allocates a new id, sets \a newTab's id, locates it just to the right of the
  existing tabs, inserts an accelerator if the tab's label contains the
  string "&p" for some value of p, adds it to the bar, and returns the
  newly allocated id.
*/


qt'QTabBar::addTab() (./qt-2.1.0/src/widgets/qtabbar.cpp:191)

int QTabBar::addTab( QTab * newTab )
{
    return insertTab( newTab );
}


/*!
  Inserts \a newTab to the tab control.

  If \a index is not specified, the tab is simply added. Otherwise
  it's inserted at the specified position.

  Allocates a new id, sets \a newTab's id, locates it respectively,
  inserts an accelerator if the tab's label contains the string "&p"
  for some value of p, adds it to the bar, and returns the newly
  allocated id.
*/


qt'QTabBar::insertTab() (./qt-2.1.0/src/widgets/qtabbar.cpp:209)

int QTabBar::insertTab( QTab * newTab, int index )
{
    newTab->id = d->id++;
    l->insert( 0, newTab );
    if ( index < 0 || index > int(lstatic->count()) )
	lstatic->append( newTab );
    else
	lstatic->insert( index, newTab );

    layoutTabs();
    updateArrowButtons();

    int p = QAccel::shortcutKey( newTab->label );
    if ( p )
	d->a->insertItem( p, newTab->id );

    return newTab->id;
}


/*!
  Removes \a tab from the tab control.
*/

qt'QTabBar::removeTab() (./qt-2.1.0/src/widgets/qtabbar.cpp:232)

void QTabBar::removeTab( QTab * tab )
{
    //#### accelerator labels??
    l->remove( tab );
    lstatic->remove( tab );
    layoutTabs();
    updateArrowButtons();
    update();
}


/*!
  Enable tab \a id if \a enable is TRUE, or disable it if \a enable is
  FALSE.  If \a id is currently selected, setTabEnabled() makes
  another tab selected.

  setTabEnabled() updates the display respectivly if this causes a
  change in \a id's status.

  \sa update(), isTabEnabled()
*/


qt'QTabBar::setTabEnabled() (./qt-2.1.0/src/widgets/qtabbar.cpp:254)

void QTabBar::setTabEnabled( int id, bool enabled )
{
    QTab * t;
    for( t = l->first(); t; t = l->next() ) {
	if ( t && t->id == id ) {
	    if ( t->enabled != enabled ) {
		t->enabled = enabled;
		d->a->setItemEnabled( t->id, enabled );
		QRect r( t->r );
		if ( !enabled && id == currentTab() ) {
		    QPoint p1( t->r.center() ), p2;
		    int m = 2147483647;
		    int distance;
		    // look for the closest enabled tab - measure the
		    // distance between the centers of the two tabs
		    for( QTab * n = l->first(); n; n = l->next() ) {
			if ( n->enabled ) {
			    p2 = n->r.center();
			    distance = (p2.x() - p1.x())*(p2.x() - p1.x()) +
				       (p2.y() - p1.y())*(p2.y() - p1.y());
			    if ( distance < m ) {
				t = n;
				m = distance;
			    }
			}
		    }
		    if ( t->enabled ) {
			r = r.unite( t->r );
			l->append( l->take( l->findRef( t ) ) );
			emit selected( t->id );
		    }
		}
		updateMask();
		repaint( r );
	    }
	    return;
	}
    }
}


/*!
  Returns TRUE if the tab with id \a id is enabled, or FALSE if it
  is disabled or there is no such tab.

  \sa setTabEnabled()
*/


qt'QTabBar::isTabEnabled() (./qt-2.1.0/src/widgets/qtabbar.cpp:302)

bool QTabBar::isTabEnabled( int id ) const
{
    QTab * t;
    for( t = l->first(); t; t = l->next() ) {
	if ( t && t->id == id )
	    return t->enabled;
    }
    return FALSE;
}



/*!\reimp
*/

qt'QTabBar::sizeHint() (./qt-2.1.0/src/widgets/qtabbar.cpp:316)

QSize QTabBar::sizeHint() const
{
    QTab * t = l->first();
    if ( t ) {
	QRect r( t->r );
	while ( (t = l->next()) != 0 )
	    r = r.unite( t->r );
	return r.size();
    } else {
	return QSize( 0, 0 );
    }
}


/*!\reimp
*/

qt'QTabBar::sizePolicy() (./qt-2.1.0/src/widgets/qtabbar.cpp:332)

QSizePolicy QTabBar::sizePolicy() const
{
    return QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
}


/*!  Paint the single tab \a t using \a p.  If and only if \a selected
  is TRUE, \a t is currently selected.

  This virtual function may be reimplemented to change the look of
  QTabBar.  If you decide to reimplement it, you may also need to
  reimplement sizeHint().
*/


qt'QTabBar::paint() (./qt-2.1.0/src/widgets/qtabbar.cpp:346)

void QTabBar::paint( QPainter * p, QTab * t, bool selected ) const
{
    style().drawTab( p, this, t, selected );

    QRect r( t->r );
    p->setFont( font() );

    int iw = 0;
    int ih = 0;
    if ( t->iconset != 0 ) {
	iw = t->iconset->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
	ih = t->iconset->pixmap( QIconSet::Small, QIconSet::Normal ).height();
    }
    int w = iw + p->fontMetrics().width( t->label ) + 4;
    int h = QMAX(p->fontMetrics().height() + 4, ih );
    paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
			  r.top() + (r.height()-h)/2,
			  w, h ), t, t->id == keyboardFocusTab() );
}

/*!
  Paints the label of tab \a t centered in rectangle \a br using
  painter \a p and draws a focus indication if \a has_focus is TRUE.
*/


qt'QTabBar::paintLabel() (./qt-2.1.0/src/widgets/qtabbar.cpp:371)

void QTabBar::paintLabel( QPainter* p, const QRect& br,
			  QTab* t, bool has_focus ) const
{

    QRect r = br;
    if ( t->iconset) {
	// the tab has an iconset, draw it in the right mode
	QIconSet::Mode mode = (t->enabled && isEnabled())
	    ? QIconSet::Normal : QIconSet::Disabled;
	if ( mode == QIconSet::Normal && has_focus )
	    mode = QIconSet::Active;
	QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode );
	int pixw = pixmap.width();
	int pixh = pixmap.height();
	r.setLeft( r.left() + pixw + 2 );
	p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap );
    }

   if ( t->enabled && isEnabled()  ) {
#if defined(_WS_WIN32_)
       if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
	   p->setPen( colorGroup().buttonText() );
       else
	   p->setPen( colorGroup().foreground() );
#else
       p->setPen( colorGroup().foreground() );
#endif
       p->drawText( r, AlignCenter | ShowPrefix, t->label );
    } else if ( style() == MotifStyle ) {
	p->setPen( palette().disabled().foreground() );
	p->drawText( r, AlignCenter | ShowPrefix, t->label );
    } else { // Windows style, disabled
	p->setPen( colorGroup().light() );
	QRect wr = r;
	wr.moveBy( 1, 1 );
	p->drawText( wr, AlignCenter | ShowPrefix, t->label );
	p->setPen( palette().disabled().foreground() );
	p->drawText( r, AlignCenter | ShowPrefix, t->label );
    }

    if ( !has_focus )
	return;

    if ( style() == WindowsStyle )
	p->drawWinFocusRect( br, backgroundColor() );
    else // shouldn't this be black, irrespective of everything?
	p->drawRect( br );
}


/*!
  Draws the mask for this tab bar.

  \internal
  This is not totally right - a few corner pixels missing.
*/


qt'QTabBar::updateMask() (./qt-2.1.0/src/widgets/qtabbar.cpp:428)

void  QTabBar::updateMask()
{
    if ( !autoMask() )
	return;
    QBitmap bm( size() );
    bm.fill( color0 );

    QPainter p;
    p.begin( &bm, this );
    p.setBrush(color1);
    p.setPen(color1);

    QTab * t;
    t = l->first();
    do {
	QTab * n = l->next();
	if ( t )
	    style().drawTabMask( &p, this, t, n == 0 );
	t = n;
    } while ( t != 0 );


    p.end();
    setMask( bm );
}

/*!
  Repaints the tab row.  All the painting is done by paint();
  paintEvent() only decides which tabs need painting and in what
  order.

  \sa paint()
*/


qt'QTabBar::paintEvent() (./qt-2.1.0/src/widgets/qtabbar.cpp:462)

void QTabBar::paintEvent( QPaintEvent * e )
{
    QPainter p( this );

    p.setBrushOrigin( rect().bottomLeft() );
    p.fillRect( 0, 0, width(), height(),
		QBrush( colorGroup().brush( QColorGroup::Background ) ));

    QTab * t;
    t = l->first();
    do {
	QTab * n = l->next();
	if ( t && t->r.intersects( e->rect() ) )
	    paint( &p, t, n == 0 );
	t = n;
    } while ( t != 0 );

    if ( d->scrolls && lstatic->first()->r.left() < 0 ) {
	QPointArray a;
	int h = height();
	if ( d->s == RoundedAbove ) {
	    p.fillRect( 0, 3, 4, h-5,
			QBrush( colorGroup().brush( QColorGroup::Background ) ));
	    a.setPoints( 5,  0,2,  3,h/4, 0,h/2, 3,3*h/4, 0,h );
	} else if ( d->s == RoundedBelow ) {
	    p.fillRect( 0, 2, 4, h-5,
			QBrush( colorGroup().brush( QColorGroup::Background ) ));
	    a.setPoints( 5,  0,0,  3,h/4, 0,h/2, 3,3*h/4, 0,h-3 );
	}

	if ( !a.isEmpty() ) {
	    p.setPen( colorGroup().light() );
	    p.drawPolyline( a );
	    a.translate( 1, 0 );
	    p.setPen( colorGroup().midlight() );
	    p.drawPolyline( a );
	}
    }
}


/*!
  This virtual functions is called by the mouse event handlers to
  determine which tab is pressed.  The default implementation returns
  a pointer to the tab whose bounding rectangle contains \a p, if
  exactly one tab's bounding rectangle contains \a p.  It returns 0
  else.

  \sa mousePressEvent() mouseReleaseEvent()
*/


qt'QTabBar::selectTab() (./qt-2.1.0/src/widgets/qtabbar.cpp:513)

QTab * QTabBar::selectTab( const QPoint & p ) const
{
    QTab * selected = 0;
    bool moreThanOne = FALSE;

    QListIterator<QTab> i( *l );
    while( i.current() ) {
	QTab * t = i.current();
	++i;

	if ( t && t->r.contains( p ) ) {
	    if ( selected )
		moreThanOne = TRUE;
	    else
		selected = t;
	}
    }

    return moreThanOne ? 0 : selected;
}


/*!\reimp
*/

qt'QTabBar::mousePressEvent() (./qt-2.1.0/src/widgets/qtabbar.cpp:537)

void QTabBar::mousePressEvent( QMouseEvent * e )
{
    QTab * t = selectTab( e->pos() );
    if ( t != 0 && t == selectTab( e->pos() ) && t->enabled ) {
	setCurrentTab( t );
    }
}


/*!\reimp
*/


qt'QTabBar::mouseReleaseEvent() (./qt-2.1.0/src/widgets/qtabbar.cpp:549)

void QTabBar::mouseReleaseEvent( QMouseEvent * )
{
}


/*!  \reimp
*/

qt'QTabBar::show() (./qt-2.1.0/src/widgets/qtabbar.cpp:556)

void QTabBar::show()
{
    //  ensures that one tab is selected.
    QTab * t = l->last();
    QWidget::show();
    if ( t )
	emit selected( t->id );
}

/*!  If a page is currently visible, returns its ID.  If no page is
  currently visible, returns either -1 or the ID of one of the pages.

  Even if the return value is not -1, you cannot assume either that
  the user can see the relevant page, or that the tab \link
  isTabEnabled() is enabled.\endlink

  When you need to display something, the return value from this
  function represents the best page to display.  That's all.

  \sa selected()
*/


qt'QTabBar::currentTab() (./qt-2.1.0/src/widgets/qtabbar.cpp:578)

int QTabBar::currentTab() const
{
    QTab * t = l->last();

    return t ? t->id : -1;
}


/*! Raises the tab with ID \a id and emits the selected() signal.

  \sa currentTab() selected() tab()
*/


qt'QTabBar::setCurrentTab() (./qt-2.1.0/src/widgets/qtabbar.cpp:591)

void QTabBar::setCurrentTab( int id )
{
    setCurrentTab( tab( id ) );
}


/*! Raises \a tab and emits the selected() signal unless the tab was
  already current.

  \sa currentTab() selected()
*/


qt'QTabBar::setCurrentTab() (./qt-2.1.0/src/widgets/qtabbar.cpp:603)

void QTabBar::setCurrentTab( QTab * tab )
{
    if ( tab && l ) {
	if ( l->last() == tab )
	    return;

	QRect r = l->last()->r;
	if ( l->findRef( tab ) >= 0 )
	    l->append( l->take() );

	d->focus = tab->id;
	updateMask();
	if ( tab->r.intersects( r ) ) {
	    repaint( r.unite( tab->r ) );
	} else {
	    repaint( r );
	    repaint( tab->r );
	}
	makeVisible( tab );
	emit selected( tab->id );
    }
}

/*!  If this tab control has keyboard focus, returns the ID of the
  tab Space will select.  Otherwise, returns -1.
*/


qt'QTabBar::keyboardFocusTab() (./qt-2.1.0/src/widgets/qtabbar.cpp:630)

int QTabBar::keyboardFocusTab() const
{
    return hasFocus() ? d->focus : -1;
}


/*!\reimp
*/

qt'QTabBar::keyPressEvent() (./qt-2.1.0/src/widgets/qtabbar.cpp:638)

void QTabBar::keyPressEvent( QKeyEvent * e )
{
    //   The right and left arrow keys move a selector, the spacebar
    //   makes the tab with the selector active.  All other keys are
    //   ignored.

    int old = d->focus;

    if ( e->key() == Key_Left ) {
	// left - skip past any disabled ones
	if ( d->focus > 0 ) {
	    QTab * t = lstatic->last();
	    while ( t && t->id != d->focus )
		t = lstatic->prev();
	    do {
		t = lstatic->prev();
	    } while ( t && !t->enabled);
	    if (t)
		d->focus = t->id;
	}
	if ( d->focus < 0 )
	    d->focus = old;
    } else if ( e->key() == Key_Right ) {
	QTab * t = lstatic->first();
	while ( t && t->id != d->focus )
	    t = lstatic->next();
	do {
	    t = lstatic->next();
	} while ( t && !t->enabled);
    if (t)
	d->focus = t->id;
    if ( d->focus >= d->id )
	d->focus = old;
    } else {
	// other keys - ignore
	e->ignore();
	return;
    }

    // if the focus moved, repaint and signal
    if ( old != d->focus ) {
	setCurrentTab( d->focus );
    }
}


/*!  Returns a pointer to the tab with ID \a id, or 0 if there is no
  such tab.
*/


qt'QTabBar::tab() (./qt-2.1.0/src/widgets/qtabbar.cpp:688)

QTab * QTabBar::tab( int id )
{
    QTab * t;
    for( t = l->first(); t; t = l->next() )
	if ( t && t->id == id )
	    return t;
    return 0;
}

/*!
  The list of QTab objects added.
*/

qt'QTabBar::tabList() (./qt-2.1.0/src/widgets/qtabbar.cpp:700)

QList<QTab> * QTabBar::tabList()
{
    return l;
}


/*!  Returns the shape of this tab bar. \sa setShape() */

QTabBar::Shape QTabBar::shape() const
{
    return d ? d->s : RoundedAbove;
}


/*!  Sets the shape of this tab bar to \a s and refreshes the bar.
*/


qt'QTabBar::setShape() (./qt-2.1.0/src/widgets/qtabbar.cpp:717)

void QTabBar::setShape( Shape s )
{
    if ( !d || d->s == s )
	return;
    //######### must recalculate heights
    d->s = s;
    updateMask();
    update();
}



/*!
  Layout all existing tabs (i.e. setting their r attribute ) according
  to their label and their iconset.
 */

qt'QTabBar::layoutTabs() (./qt-2.1.0/src/widgets/qtabbar.cpp:733)

void QTabBar::layoutTabs()
{
    if ( lstatic->isEmpty() )
	return;

    int hframe, vframe, overlap;
    style().tabbarMetrics( this, hframe, vframe, overlap );
    QFontMetrics fm = fontMetrics();
    int x = 0;
    QRect r;
    QTab *t;
    for ( t = lstatic->first(); t; t = lstatic->next() ) {
	int lw = fm.width( t->label );
	int iw = 0;
	int ih = 0;
	if ( t->iconset != 0 ) {
	    iw = t->iconset->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
	    ih = t->iconset->pixmap( QIconSet::Small, QIconSet::Normal ).height();
	}
	int h = QMAX( fm.height(), ih );

	h += vframe;
	t->r.setRect( x, 0, lw + hframe + iw, h );
	x += t->r.width() - overlap;
	r = r.unite( t->r );
    }
    for ( t = lstatic->first(); t; t = lstatic->next() )
	t->r.setHeight( r.height() );
}

/*!
  \reimp
*/

qt'QTabBar::focusInEvent() (./qt-2.1.0/src/widgets/qtabbar.cpp:766)

void QTabBar::focusInEvent( QFocusEvent * )
{
    QTab *t = l->first();
    for ( ; t; t = l->next() ) {
	if ( t->id == d->focus ) {
	    QPainter p;
	    p.begin( this );
	    QRect r = t->r;
	    p.setFont( font() );

	    int iw = 0;
	    int ih = 0;
	    if ( t->iconset != 0 ) {
		iw = t->iconset->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
		ih = t->iconset->pixmap( QIconSet::Small, QIconSet::Normal ).height();
	    }
	    int w = iw + p.fontMetrics().width( t->label ) + 4;
	    int h = QMAX(p.fontMetrics().height() + 4, ih );
	    paintLabel( &p, QRect( r.left() + ( r.width() -w ) /2 - 3,
				   r.top() + ( r.height()-h ) / 2,
				   w, h ), t, TRUE );
	    p.end();
	}
    }
}

/*!
  \reimp
*/

qt'QTabBar::focusOutEvent() (./qt-2.1.0/src/widgets/qtabbar.cpp:795)

void QTabBar::focusOutEvent( QFocusEvent * )
{
    QTab *t = l->first();
    for ( ; t; t = l->next() ) {
	if ( t->id == d->focus ) {
	    QPainter p;
	    p.begin( this );
	    p.setBrushOrigin( rect().bottomLeft() );
	    QRect r = t->r;
	    p.setFont( font() );

	    int iw = 0;
	    int ih = 0;
	    if ( t->iconset != 0 ) {
		iw = t->iconset->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
		ih = t->iconset->pixmap( QIconSet::Small, QIconSet::Normal ).height();
	    }
	    int w = iw + p.fontMetrics().width( t->label ) + 4;
	    int h = QMAX(p.fontMetrics().height() + 4, ih );
	    p.fillRect( QRect( r.left() + ( r.width() -w ) / 2 - 4,
				   r.top() + ( r.height()-h ) / 2 - 1,
			       w + 2, h + 2 ), colorGroup().brush(QColorGroup::Background ) );
	    paintLabel( &p, QRect( r.left() + ( r.width() -w ) /2 - 3,
				   r.top() + ( r.height()-h ) / 2,
				   w, h ), t, FALSE );
	    p.end();
	}
    }
}

/*!
  \reimp
*/

qt'QTabBar::resizeEvent() (./qt-2.1.0/src/widgets/qtabbar.cpp:828)

void QTabBar::resizeEvent( QResizeEvent * )
{
    const int arrowWidth = 16;
    d->rightB->setGeometry( width() - arrowWidth, 0, arrowWidth, height() );
    d->leftB->setGeometry( width() - 2*arrowWidth, 0, arrowWidth, height() );
    layoutTabs();
    updateArrowButtons();
}


qt'QTabBar::scrollTabs() (./qt-2.1.0/src/widgets/qtabbar.cpp:837)

void QTabBar::scrollTabs()
{
    QTab* left = 0;
    QTab* right = 0;
    for ( QTab* t = lstatic->first(); t; t = lstatic->next() ) {
	if ( t->r.left() < 0 && t->r.right() > 0 )
	    left = t;
	if ( t->r.left() < d->leftB->x() )
	    right = t;
    }

    if ( sender() == d->leftB )
	makeVisible( left );
    else  if ( sender() == d->rightB )
	makeVisible( right );
}


qt'QTabBar::makeVisible() (./qt-2.1.0/src/widgets/qtabbar.cpp:854)

void QTabBar::makeVisible( QTab* tab  )
{
    bool tooFarLeft = ( tab && tab->r.left() < 0 );
    bool tooFarRight = ( tab && tab->r.right() >= d->leftB->x() );

    if ( !d->scrolls || ( !tooFarLeft && ! tooFarRight ) )
	return;

    layoutTabs();

    int offset = 0;

    if ( tooFarLeft )
	offset = tab == lstatic->first() ? 0 : tab->r.left() - 8;
    else if ( tooFarRight ) {
	offset = tab->r.right() - d->leftB->x() + 1;
    }

    for ( QTab* t = lstatic->first(); t; t = lstatic->next() )
	t->r.moveBy( -offset, 0 );

    d->leftB->setEnabled( offset != 0 );
    d->rightB->setEnabled( lstatic->last()->r.right() >= d->leftB->x() );


    update();
}


qt'QTabBar::updateArrowButtons() (./qt-2.1.0/src/widgets/qtabbar.cpp:882)

void QTabBar::updateArrowButtons()
{
    bool b = lstatic->last() ?
	lstatic->last()->r.right() > width() : FALSE;
    if ( d->scrolls == b )
	return;
    d->scrolls = b;
    if ( d->scrolls ) {
	d->leftB->setEnabled( FALSE );
	d->rightB->setEnabled( TRUE );
	d->leftB->show();
	d->rightB->show();
    } else {
	d->leftB->hide();
	d->rightB->hide();
    }
}